Hello,
In the Perl API, how do I get the names/values of all custom fields
attached to a ticket? I looked at the documentation, but I only see ways
to check for custom fields globally, not how to get a list of all the
custom fields that apply to a single ticket.
I am using 3.8.
Thanks!
Chris
Hello,
In the Perl API, how do I get the names/values of all custom fields
attached to a ticket? I looked at the documentation, but I only see
ways to check for custom fields globally, not how to get a list of
all the custom fields that apply to a single ticket.
my $Ticket = RT::Ticket->new( $CurrentUser );
$Ticket->Load(ID);
my $CustomFields = $Ticket->CustomFields;
while (my $CustomField = $CustomFields->Next) {
print $CustomField->Name.“: “.$CustomField->Content.”\n”;
}
without testing, it should looks like this
Easter-eggs Spécialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com
Hi Emmanuel,
Thanks for your great reply!
Emmanuel Lacour writes:
my $CustomFields = $Ticket->CustomFields;
This works, but I don’t see it documented here0. Is that expected?
while (my $CustomField = $CustomFields->Next) {
print $CustomField->Name.“: “.$CustomField->Content.”\n”;
}
This only partially works as “Content” is not a known method.
I also tried calling the custom field name as a method on the ticket
object, since many other fields work that way, but that didn’t work (no
such method).
I will keep on looking, and if you have any other suggestions I would be
very eager to hear them
Thank you!
Chris
I think I eventually found what I want[0]:
$ticket->CustomFieldValuesAsString($custom_field_name);
However, on my version of RT this says:
RT::CustomFieldValuesAsString Unimplemented in main. (rt-dump.pl line 91)
Any ideas?
0: RT::Record - RT 3.8.17 Documentation - Best Practical
I think I eventually found what I want[0]:
$ticket->CustomFieldValuesAsString($custom_field_name);
$ticket->FirstCustomFieldValue($custom_field_name);
looks what you’re lookign for
RT::Ticket is based on RT::Record, so you can user every methods
available on this last one on a ticket.
Easter-eggs Spécialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com
Emmanuel Lacour writes:
$ticket->FirstCustomFieldValue($custom_field_name);
Dude, that totally works! Thanks so much for your help, I owe you one!