[rt-users] Help with a template

Matt Zagrabelny mzagrabe at d.umn.edu
Tue Dec 1 17:35:09 EST 2015


On Tue, Dec 1, 2015 at 4:21 PM, Joe Kirby <kirby at umbc.edu> wrote:
> I have a need to create a child ticket and pass on the values for a shared
> custom field.
>
> This works fine when passing a field which is limited to 1 value however I
> now have a multi-value custom field and I cannot find any examples of how to
> pass the secondary values if they exist.

There are a couple of ways.

1) Use the built-in method.

CustomFieldValuesAsString

more about it can be found in:

lib/RT/Record.pm

2) Have full control over the output.

Here is an example that builds an HTML list:

{
 my $cf = $Ticket->LoadCustomFieldByIdentifier('Multimedia Hub
Equipment');
 my $equipment = $cf->ValuesForObject($Ticket)->ItemsArrayRef;

 $html_equipment = 'No equipment listed.';

 if (@$equipment > 0) {
     $html_equipment = '<ul>';
     for my $item (@$equipment) {
         my $content = $item->Content;
         RT::Interface::Web::EscapeHTML(\$content);
         $html_equipment .= '<li>'.$content.'</li>';
     }
     $html_equipment .= '</ul>';
 }

 $html_equipment;
 }

Cheers,

-m



More information about the rt-users mailing list