[rt-users] CFs in Templates?
JB Segal
jb at smarterliving.com
Fri Dec 14 19:09:11 EST 2007
Quoth JB Segal (jb at smarterliving.com):
> Kenn,
> This is fabulous! Thank you so much.
> Would you mind me sticking this in to the wiki to fix the broken
> information that's in there?
I tweaked the wiki, mainly noting that what was there doesn't work, but
also including a bit of the howto.
Further wiki searching lead me to
http://wiki.bestpractical.com/view/AddCustomFieldstoTemplates
and Christopher C. Weis' helpful addition. I'm almost there. But...
My problem now is...
This works:
{ my $Pvalues = $Ticket->CustomFieldValues('Product');
my $AAvalues = $Ticket->CustomFieldValues('Application Area');
my $OUTPUT;
while ( my $value = $Pvalues->Next ) {
$OUTPUT .= "X-Product: ";
$OUTPUT .= $value->Content;
$OUTPUT .= "\n";
}
while ( my $value = $AAvalues->Next ) {
$OUTPUT .= "X-Application-Area: ";
$OUTPUT .= $value->Content;
$OUTPUT .= "\n";
}
$OUTPUT;
}
but is, of course, ugly.
I'm aiming at collapsing this in to a single, extensible loop,
something like:
{ my @CFlist = ('Product', 'Application Area');
foreach my $CFname (@CFlist) {
my $CFvalues = $Ticket->CustomFieldValues($CFname);
my $OUTPUT;
while ( my $value = $CFvalues->Next ) {
$CFName =~ s/ /-/g;
$OUTPUT .= "X-$CFname: ";
$OUTPUT .= ($value->Content eq '') ? $value->Content : 'unset';
$OUTPUT .= "\n";
}
$OUTPUT;
}
}
but this doesn't work.
What am I missing? It's probably REALLY stupid... really, I don't speak
perl.
Thanks in advance and I hope everyone has a great weekend!
JB
--
JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com
More information about the rt-users
mailing list