Accessing Transactional Custom Fields From a Scrip

Hi List,

Does anybody know how to access the value of a transactional custom
field from a script? I have some per-transaction custom fields and I
want to be able to access its contents, if the user chooses to fill it
in when updating a ticket. However, when I try to access the field’s
value, I end up with the value for the per-ticket custom field
instead. Here’s my code:

Condition: On Transaction
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

Custom action preparation code:

return 1;

Custom action cleanup code:

my $CFName = ‘Billable (min)’;
my $cfvalue = $self->TicketObj->FirstCustomFieldValue( $CFName );
open(DEBUGFILE,">>/tmp/debugcf");
print DEBUGFILE “$CFName :: $cfvalue \n”;
close(DEBUGFILE);

What am I doing wrong here? Can anybody offer any tips? Tried the
wiki to no avail. :frowning:

Chris

Hi Chris,

According to documentation on the Wiki, there is a
’$self->TransactionObj’, that should be used instead of
’$self->TicketObj’ to access the transactional custom fields.

I have never got this to work, unfortunately…

I ended up with the following scrip, that does not pick up any values:

my $Transaction = $self->TransactionObj;
my $CustomFieldValues=$Transaction->CustomFieldValues( “Internal status”
);
$RT::Logger->error( “Parsing transaction custom fields:” );

while (my $CustomFieldValue = $CustomFieldValues->Next) {
$RT::Logger->error( "Value: ".$CustomFieldValue->Content );
};

$RT::Logger->error( “Done!” );
return (1);

Best Regards - Anders Ekstrand

I have never got this to work, unfortunately…

I ended up with the following scrip, that does not pick up any values:

my $Transaction = $self->TransactionObj;
my $CustomFieldValues=$Transaction->CustomFieldValues( “Internal status”

Bummer. The whole system of accessing Custom Fields from scripts
seems so obtuse to me. Why must we call all these methods to get at
the values? I think it would be nicer from a programming standpoint
to be able to do things like this:

while my $a_custom_field (keys %{$self->TransactionObj->CustomFields}) {
print “$a_custom_field →
$self->TransactionObj->CustomFields->{$a_custom_field} \n”;
}

Perhaps these data structures are already in place and I just don’t
know how to access them? Can somebody enlighten me?

thx,

Chris