The use of $Ticket{'TOP'}->CustomFieldValues($fieldname) with RT::Action::CreateTickets

Hello,

It seems that one cannot load the values of a CF with $Ticket{‘TOP’}->CustomFieldValues($fieldname). The result is an empty variable. I’ve confirmed that the foreach works for each of the $cfname in the @cflist since I get log entries for them but $cfvs->Next doesn’t produce a value (nothing is logged).

===Create-Ticket: Investigation
{
my @cflist = [ ‘Customfield1’, ‘Customfield2’, ‘etc’];
our @CFTEXT;
foreach my $cfname (@cflist) {
RT::Logger->info($cfname);
my $cfvs = $Tickets{“TOP”}->CustomFieldValues($cfname);
while (my $cfv = $cfvs->Next) {
RT::Logger->info($cfname.“: “.$cfv->Content);
push @CFTEXT, “CF-”.$cfname.”: “.$cfv->Content;
}
}
}
Queue: Investigations
Parents: TOP
Status: open
{ join(”\n”, @CFTEXT) }
Content-Type: text/html
Content:

{$Tickets{“TOP”}->Transactions->First->Content}

ENDOFCONTENT

LOGS from the foreach() (but not from the while()):
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer ID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Language (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Name (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Email (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Email Tech (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Type (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Name (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device O/S (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Control Panel (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Country (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Groups (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Ticket Priority (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Managed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer SystemDB (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Price (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Type (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Facility (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Bits (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Addresses (template:8)

I’ve also tried loading the CF using $Tickets{“TOP”}->LoadCustomFieldByIdentifier($cfname) but this does not work either.

Basically I’m waning to copy a list of CFs from $Tickets{‘TOP’} to the newly created one.

Thank you.

Landon Stewart : lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

signature.asc (203 Bytes)

You need to output “CustomField-$cfname” as the key, not “CF-$cfname”.On Tue, 10 Mar 2015 6:31 pm Landon Stewart lstewart@iweb.com wrote:

Hello,

It seems that one cannot load the values of a CF with
$Ticket{‘TOP’}->CustomFieldValues($fieldname). The result is an empty
variable. I’ve confirmed that the foreach works for each of the $cfname in
the @cflist since I get log entries for them but $cfvs->Next doesn’t
produce a value (nothing is logged).

===Create-Ticket: Investigation
{
my @cflist = [ ‘Customfield1’, ‘Customfield2’, ‘etc’];
our @CFTEXT;
foreach my $cfname (@cflist) {
RT::Logger->info($cfname);
my $cfvs = $Tickets{“TOP”}->CustomFieldValues($cfname);
while (my $cfv = $cfvs->Next) {
RT::Logger->info($cfname.“: “.$cfv->Content);
push @CFTEXT, “CF-”.$cfname.”: “.$cfv->Content;
}
}
}
Queue: Investigations
Parents: TOP
Status: open
{ join(”\n”, @CFTEXT) }
Content-Type: text/html
Content:

{$Tickets{“TOP”}->Transactions->First->Content}

ENDOFCONTENT

LOGS from the foreach() (but not from the while()):
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer ID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Language (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Name (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Email (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Email Tech (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Type (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Name (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device O/S (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Control Panel
(template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Country (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Groups (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Ticket Priority
(template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Managed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer SystemDB (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Price (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Type (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Facility (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Bits (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Addresses (template:8)

I’ve also tried loading the CF using
$Tickets{“TOP”}->LoadCustomFieldByIdentifier($cfname) but this does not
work either.

Basically I’m waning to copy a list of CFs from $Tickets{‘TOP’} to the
newly created one.

Thank you.

Landon Stewart : lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

@Alex:
CreateTickets support both, CustomField and CF keys [1].

@Landon:
Why don’t you simply add this lines to you template, as you are using a
static customfield list and don’t want to add all customfields (assuming
you customfields are single value fields):

CF-Customfield1: {$Tickets{‘TOP’}->FirstCustomFieldValue(‘Customfield1’)}
CF-Customfield2: {$Tickets{‘TOP’}->FirstCustomFieldValue(‘Customfield2’)}
CF-etc: {$Ticket{‘TOP’}->FirstCustomFieldValue(‘etc’)}

Chris

[1]
rt/lib/RT/Action/CreateTickets.pm at stable · bestpractical/rt · GitHub 10.03.2015 um 10:29 schrieb Alex Peters:

You need to output “CustomField-$cfname” as the key, not “CF-$cfname”.

On Tue, 10 Mar 2015 6:31 pm Landon Stewart <lstewart@iweb.com mailto:lstewart@iweb.com> wrote:

Hello,

It seems that one cannot load the values of a CF
with $Ticket{'TOP'}->CustomFieldValues($fieldname).  The result is
an empty variable.  I've confirmed that the foreach works for each
of the $cfname in the @cflist since I get log entries for them but
$cfvs->Next doesn't produce a value (nothing is logged).

===Create-Ticket: Investigation
{
  my @cflist = [ 'Customfield1', 'Customfield2', 'etc'];
  our @CFTEXT;
  foreach my $cfname (@cflist) {
    RT::Logger->info($cfname);
    my $cfvs = $Tickets{"TOP"}->CustomFieldValues($cfname);
    while (my $cfv = $cfvs->Next) {
      RT::Logger->info($cfname.": ".$cfv->Content);
      push @CFTEXT, "CF-".$cfname.": ".$cfv->Content;
    }
  }
}
Queue: Investigations
Parents: TOP
Status: open
{ join("\n", @CFTEXT) }
Content-Type: text/html
Content:<pre>{$Tickets{"TOP"}->Transactions->First->Content}</pre>
ENDOFCONTENT

LOGS from the foreach() (but not from the while()):
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer ID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Language
(template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Name (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Email (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Email Tech
(template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Type (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Name (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Status (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device O/S (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Control Panel
(template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Country (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Groups (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Ticket Priority
(template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer Managed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Customer SystemDB
(template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Price (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Service Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device DBID (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Created (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Closed (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Type (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Facility (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Bits (template:8)
[16779] [Tue Mar 10 06:52:53 2015] [info]: Device Addresses (template:8)



I've also tried loading the CF
using$Tickets{"TOP"}->LoadCustomFieldByIdentifier($cfname) but this
does not work either.

Basically I'm waning to copy a list of CFs from $Tickets{'TOP'} to
the newly created one.

Thank you.

Landon Stewart : lstewart@iweb.com <mailto:lstewart@iweb.com>
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

You need to output “CustomField-$cfname” as the key, not “CF-$cfname”.

CF-$cfname should work as well but more importantly nothing is being outputted there which is the problem I’m most concerned with.

Landon Stewart : lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

signature.asc (203 Bytes)

@Alex:
CreateTickets support both, CustomField and CF keys [1].

@Landon:
Why don’t you simply add this lines to you template, as you are using a
static customfield list and don’t want to add all customfields (assuming
you customfields are single value fields):

CF-Customfield1: {$Tickets{‘TOP’}->FirstCustomFieldValue(‘Customfield1’)}
CF-Customfield2: {$Tickets{‘TOP’}->FirstCustomFieldValue(‘Customfield2’)}
CF-etc: {$Ticket{‘TOP’}->FirstCustomFieldValue(‘etc’)}

The problem with using FirstCustomFieldValue() is that I’d, of course, only get the first value for each CF but I want all the values for each CF to be copied over.

Landon Stewart : lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932

signature.asc (203 Bytes)

Hello RT-Users,

Nevermind! :slight_smile:

I’m doing a chain of RT::Action::CreateTickets and it turns out my problem was that the custom fields were not being set before the Investigation ticket creation and therefor the CF’s had no values. Once the issue with that was resolved it all started working perfectly.

Landon Stewart : lstewart@iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com : +1 (888) 909-4932> On Mar 10, 2015, at 12:15 AM, Landon Stewart lstewart@iweb.com wrote:

Hello,

It seems that one cannot load the values of a CF with $Ticket{‘TOP’}->CustomFieldValues($fieldname). The result is an empty variable. I’ve confirmed that the foreach works for each of the $cfname in the @cflist since I get log entries for them but $cfvs->Next doesn’t produce a value (nothing is logged).

===Create-Ticket: Investigation
{
my @cflist = [ ‘Customfield1’, ‘Customfield2’, ‘etc’];
our @CFTEXT;
foreach my $cfname (@cflist) {
RT::Logger->info($cfname);
my $cfvs = $Tickets{“TOP”}->CustomFieldValues($cfname);
while (my $cfv = $cfvs->Next) {
RT::Logger->info($cfname.“: “.$cfv->Content);
push @CFTEXT, “CF-”.$cfname.”: “.$cfv->Content;
}
}
}
Queue: Investigations
Parents: TOP
Status: open
{ join(”\n”, @CFTEXT) }
Content-Type: text/html
Content:

{$Tickets{“TOP”}->Transactions->First->Content}

ENDOFCONTENT

signature.asc (203 Bytes)