Help with a template

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.

Here is my current template that brings the first value

Any help is appreciated

Thanks

Joe

===Create-Ticket: DoIT-ITNM-OutReach
Referred-To-By: {$Tickets{‘TOP’}->Id}
Queue: 2234
InitialPriority: 99
FinalPriority: 99
Status: resolved
Requestor: {$Tickets{‘TOP’}->RequestorAddresses}
AdminCc: {$Tickets{‘TOP’}->Owner}
ITNM-Contact-Type: {$Tickets{‘TOP’}->FirstCustomFieldValue(‘ITNM-Contact-Type’)}
ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue(‘ITNM-Topic’)}
Content: The Online Learning team has performed an outreach and would like to track this for planning purposes. Please refer to the linked ticket for specific details.
ENDOFCONTENT

Joe Kirby , Assistant Vice President, Business Systems
Division of Information Technology (DoIT)
Support Response - http://www.umbc.edu/doit
Administration 627
Office - 410-455-3020
Email - kirby@umbc.edu

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

  1. 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 = ‘

    ’;
    for my $item (@$equipment) {
    my $content = $item->Content;
    RT::Interface::Web::EscapeHTML($content);
    $html_equipment .= ‘
  • ’.$content.’
  • ’;
    }
    $html_equipment .= ‘
’;
}

$html_equipment;
}

Cheers,

-m

Matt

I appreciate the suggestion however as a non-perl programmer I am not able to transition this to my template

I was hoping to have some command that would replace this line in the template so the child ticket could receive all the values from the parent as I am creating this dynamical via script/template

ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue('ITNM-Topic’)}

If the code provided does that and my lack of knowledge of this scripting language is the issue please just let me know and I will look into other options

Thanks

Joe

Joe Kirby , Assistant Vice President, Business Systems
Division of Information Technology (DoIT)
Support Response - http://www.umbc.edu/doit
Administration 627
Office - 410-455-3020
Email - kirby@umbc.edu> On Dec 1, 2015, at 5:35 PM, Matt Zagrabelny mzagrabe@d.umn.edu wrote:

On Tue, Dec 1, 2015 at 4:21 PM, Joe Kirby kirby@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

  1. 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 = ‘

    ’;
    for my $item (@$equipment) {
    my $content = $item->Content;
    RT::Interface::Web::EscapeHTML($content);
    $html_equipment .= ‘
  • ’.$content.’
  • ’;
    }
    $html_equipment .= ‘
’;
}

$html_equipment;
}

Cheers,

-m

Matt

I appreciate the suggestion however as a non-perl programmer I am not able
to transition this to my template

Sure.

I was hoping to have some command that would replace this line in the
template so the child ticket could receive all the values from the parent as
I am creating this dynamical via script/template

ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue('ITNM-Topic’)}

Just replace the “FirstCustomFieldValue” with “CustomFieldValuesAsString”.

-m

Thanks Matt

When I do this ITNM-Topic: {$Tickets{‘TOP’}->CustomFieldValuesAsString('ITNM-Topic’)} I still just get the first 1 in the list for the child ticket. It show fine in the parent ticket of course but is not transferring down to the child.

I am on 4.2.11

I appreciate your quick responses and ideas

I included a snapshot of the parent and child in case that helped.

Joe

Joe Kirby , Assistant Vice President, Business Systems
Division of Information Technology (DoIT)
Support Response - http://www.umbc.edu/doit
Administration 627
Office - 410-455-3020
Email - kirby@umbc.edu> On Dec 2, 2015, at 10:38 AM, Matt Zagrabelny mzagrabe@d.umn.edu wrote:

On Wed, Dec 2, 2015 at 9:35 AM, Joe Kirby kirby@umbc.edu wrote:

Matt

I appreciate the suggestion however as a non-perl programmer I am not able
to transition this to my template

Sure.

I was hoping to have some command that would replace this line in the
template so the child ticket could receive all the values from the parent as
I am creating this dynamical via script/template

ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue('ITNM-Topic’)}

Just replace the “FirstCustomFieldValue” with “CustomFieldValuesAsString”.

-m

Hi Joe,

This is a guess - as we don’t make use of creating child tickets with
templates.

Replace the line, “ITNM-Topic:
{$Tickets{‘TOP’}->CustomFieldValuesAsString('ITNM-Topic’)}” with the
following:

{
my $cf = $Tickets{TOP}->LoadCustomFieldByIdentifier(‘ITNM-Topic’);
my $topics = $cf->ValuesForObject($Tickets{TOP})->ItemsArrayRef;

join “\n”,
map { "ITNM-Topic: " . $_->Content }
@$topics
;
}

The idea here is to insert into the template a line of:

ITNM-Topic: [blah]

for each value in your CF.

Alternatively to test things out, use the original line and an additional
line to see if you can pass multiple values to a child ticket’s CF:

ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue('ITNM-Topic’)}
ITNM-Topic: testing_multiple_values

Hopefully that child ticket will have two values in its ITNM-Topic CF.

Hope that helps!

-mOn Wed, Dec 2, 2015 at 9:56 AM, Joe Kirby kirby@umbc.edu wrote:

Thanks Matt

When I do this ITNM-Topic:
{$Tickets{‘TOP’}->CustomFieldValuesAsString('ITNM-Topic’)} I still just get
the first 1 in the list for the child ticket. It show fine in the parent
ticket of course but is not transferring down to the child.

I am on 4.2.11

I appreciate your quick responses and ideas

I included a snapshot of the parent and child in case that helped.

Joe

Joe Kirby , Assistant Vice President, Business Systems
Division of Information Technology (DoIT)
Support Response - http://www.umbc.edu/doit
Administration 627
Office - 410-455-3020
Email - kirby@umbc.edu

On Dec 2, 2015, at 10:38 AM, Matt Zagrabelny mzagrabe@d.umn.edu wrote:

On Wed, Dec 2, 2015 at 9:35 AM, Joe Kirby kirby@umbc.edu wrote:

Matt

I appreciate the suggestion however as a non-perl programmer I am not able
to transition this to my template

Sure.

I was hoping to have some command that would replace this line in the
template so the child ticket could receive all the values from the parent
as
I am creating this dynamical via script/template

ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue('ITNM-Topic’)}

Just replace the “FirstCustomFieldValue” with “CustomFieldValuesAsString”.

-m

Thank you so much!!!

This worked great

I really do appreciate it.

Joe

Joe Kirby , Assistant Vice President, Business Systems
Division of Information Technology (DoIT)
Support Response - http://www.umbc.edu/doit
Administration 627
Office - 410-455-3020
Email - kirby@umbc.edu> On Dec 2, 2015, at 11:14 AM, Matt Zagrabelny mzagrabe@d.umn.edu wrote:

Hi Joe,

This is a guess - as we don’t make use of creating child tickets with templates.

Replace the line, “ITNM-Topic: {$Tickets{‘TOP’}->CustomFieldValuesAsString('ITNM-Topic’)}” with the following:

{
my $cf = $Tickets{TOP}->LoadCustomFieldByIdentifier(‘ITNM-Topic’);
my $topics = $cf->ValuesForObject($Tickets{TOP})->ItemsArrayRef;

join “\n”,
map { "ITNM-Topic: " . $_->Content }
@$topics
;
}

The idea here is to insert into the template a line of:

ITNM-Topic: [blah]

for each value in your CF.

Alternatively to test things out, use the original line and an additional line to see if you can pass multiple values to a child ticket’s CF:

ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue('ITNM-Topic’)}
ITNM-Topic: testing_multiple_values

Hopefully that child ticket will have two values in its ITNM-Topic CF.

Hope that helps!

-m

On Wed, Dec 2, 2015 at 9:56 AM, Joe Kirby <kirby@umbc.edu mailto:kirby@umbc.edu> wrote:
Thanks Matt

When I do this ITNM-Topic: {$Tickets{‘TOP’}->CustomFieldValuesAsString('ITNM-Topic’)} I still just get the first 1 in the list for the child ticket. It show fine in the parent ticket of course but is not transferring down to the child.

I am on 4.2.11

I appreciate your quick responses and ideas

I included a snapshot of the parent and child in case that helped.

<Screen Shot 2015-12-02 at 10.55.34 AM.png><Screen Shot 2015-12-02 at 10.54.57 AM.png>

Joe

Joe Kirby , Assistant Vice President, Business Systems
Division of Information Technology (DoIT)
Support Response - http://www.umbc.edu/doit http://www.umbc.edu/doit
Administration 627
Office - 410-455-3020 tel:410-455-3020
Email - kirby@umbc.edu mailto:kirby@umbc.edu

On Dec 2, 2015, at 10:38 AM, Matt Zagrabelny <mzagrabe@d.umn.edu mailto:mzagrabe@d.umn.edu> wrote:

On Wed, Dec 2, 2015 at 9:35 AM, Joe Kirby <kirby@umbc.edu mailto:kirby@umbc.edu> wrote:

Matt

I appreciate the suggestion however as a non-perl programmer I am not able
to transition this to my template

Sure.

I was hoping to have some command that would replace this line in the
template so the child ticket could receive all the values from the parent as
I am creating this dynamical via script/template

ITNM-Topic: {$Tickets{‘TOP’}->FirstCustomFieldValue('ITNM-Topic’)}

Just replace the “FirstCustomFieldValue” with “CustomFieldValuesAsString”.

-m