AddCustomFieldstoTemplates
To add just one or more Custom Fields to a Template, instead of extracting the whole lot, simply use this code fragment.
Should work in scrips as well
{$Ticket->FirstCustomFieldValue('Your Custom Field Name');}
The Field name to enter is the one that is displayed in the ticket window, not its custom field name that ExtractCustomFieldValues uses. Make sure you include the single quotes and the semi colon between the last pair of brackets.
Richard Ellis Sun Microsystems
To extend upon Richard's idea and use multi-valued Custom Fields in a Template, the following seems to work for me:
{ my $values = $Ticket->CustomFieldValues('SomeCustomField'); my $OUTPUT; while ( my $value = $values->Next ) { $OUTPUT .= "Here's your value --->"; $OUTPUT .= $value->Content; $OUTPUT .= "<---\n"; } $OUTPUT; }
Christopher C. Weis
To collapse this into a one-liner with values separated by a comma...
{ join ', ', map { $_->Content } @{ $Ticket->CustomFieldValues( 'CUSTOM FIELD NAME' )->ItemsArrayRef() }; }
This should behave properly for both single-value and multi-value CustomFields, assuming that the named CF is valid for the current Ticket. This snippet works for me on RT 3.6 running on Debian Lenny.
-- Stephen R. Scaffidi