[rt-users] I just can't figure out how to get the values from mycustom fields!

Stephen Turner sturner at MIT.EDU
Mon Mar 5 13:33:59 EST 2007


At Monday 3/5/2007 03:08 AM, Brian Kjelin Olsen wrote:
>Please - Any clues?
>It would be most appreciated.
>
>Med venlig hilsen / Best regards
>Brian Kjelin Olsen
>Schilling A/S
>-----Oprindelig meddelelse-----
>Fra: rt-users-bounces at lists.bestpractical.com 
>[mailto:rt-users-bounces at lists.bestpractical.com] 
>  På vegne af Brian Kjelin Olsen
>Sendt: 4. marts 2007 10:26
>Til: rt-users at lists.bestpractical.com
>Emne: [rt-users] I just can't figure out how to 
>get the values from mycustom fields!
>
>Hi everyone
>
>I just can't figure how to get the values of 
>custom fields on ticket transactions from scrip.
>As an example I have made this small scrip where 
>I print the field names and then try to get the values from those fields.
>
>--- Scrip example ---
>my $k=""; my $v="";
>$RT::Logger->debug("Get names of transaction 
>Custom fields from the ticket object");
>if (my $TCFs = $self->TicketObj->TransactionCustomFields()) {
>     while (my $CF = $TCFs->Next()) {
>         $RT::Logger->debug("Get values from 
> transaction custom field '" . $CF->Name . "' from the transaction object");
>         my %values = $self->TransactionObj->CustomFieldValues($CF->Name);
>         while (($k,$v) = each %values) {
>             $RT::Logger->debug("$k => $v");
>         }
>         $RT::Logger->debug("End of getting 
> values from transaction custom field '" . 
> $CF->Name . "' from the transaction object");
>     }
>}
>$RT::Logger->debug("End of getting names of 
>transaction Custom fields from the ticket object");
>---------------------


It looks like you're pretty close -

$self->TransactionObj->CustomFieldValues($CF->Name) 
will give you an ObjectCustomFieldValues 
collection object - each member of the collection 
is an ObjectCustomFieldValue object. You can 
iterate over the collection and see the values something like this:

my $values = $self->TransactionObj->CustomFieldValues($CF->Name);
while (my $CFV = $values->Next() ) {
     $RT::Logger->debug($CFV->Content);
}


Steve




More information about the rt-users mailing list