[Rt-devel] Obtain values of custom fields

Alejandro Imass aimass at cc.com.ve
Tue Aug 5 15:12:49 EDT 2008

Suppose the Custom Field Name is 'CF_NAME'

# (1) Get you ticket object somehow, for example:
my $ticketObj = $self->TicketObj;
my $queueObj = $self->TicketObj->QueueObj; #example how to get Queue
from Ticket

# (2) If you are certain it's only ONE value (will break on
multiple-select fields!)
my $cfValue = $ticketObj->CustomFieldValues('CF_NAME')->Next;
my $txtValue = $cfValue->Content if defined $cfValue;

# (2a) A better option: check for multiple-values
my @simpleValues = ( );
  push @simpleValues, $_->Content;

# @simpleValues now contains the stored values of custom field of name
CF_NAME.... This is _usually_ only one value so al you need is

CAVEAT: dunno if $ticketObj->CustomFieldValues->Next breaks if wrong
custom field. It's best to write:

# (2a+) better yet: check for multiple-values safely
my @simpleValues = ( );
my $cfValues = $ticketObj->CustomFieldValues('CF_NAME');
    push @simpleValues, $_->Content;
} if defined $cfValues; 

Besides, the Next() call is a lot clearer this way.

Alejandro Imass

El lun, 04-08-2008 a las 22:51 -0430, Eva Duque escribió:
> Hello everyone,
>  I'm manipulating the fields customizable and would like to know how to
> get his ID and its specific value at a given time for use in the action
> of a scrip for example. If someone has worked with this and can help me,
> am very grateful to you.
> --------
> Eve
> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel

More information about the Rt-devel mailing list