Obtain values of custom fields

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

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 = ( );
while($ticketObj->CustomFieldValues(‘CF_NAME’)->Next){
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
$simpleValues[0]

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’);
do{
while($cfValues->Next){
push @simpleValues, $_->Content;
}
} if defined $cfValues;

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

Cheers!
Alejandro ImassEl 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: The rt-devel Archives