Getting ticket's custom field values from within scrip?!

hi
i’m getting kind of desperate.
i tried nearly everything, yet i can’t succed.
i’m using rt 3.0.6, and my final scrip action looks like:

– action
open(OUT, “>”, “/tmp/scrip.test”);

my @a = $self->TicketObj->FirstCustomFieldValue(‘worktime-a’);
require Data::Dumper;
print OUT "7: " . Data::Dumper::Dumper(@a);

my $cfx = new RT::CustomField( $self->TransactionObj->CreatorObj );
print OUT “8: $cfx\n”;
($id,$msg) = $cf->LoadByNameAndQueue (‘Name’=>‘worktime-a’, ‘Queue’ => $self->TicketObj->QueueObj->Id);
print OUT “9: $id | $msg\n”;
if (! $id) {
($id,$msg) = $cf->LoadByNameAndQueue (‘Name’=>‘worktime-a’, ‘Queue’ => 0);
print OUT “9a: $id | $msg\n”;
}
unless ($id) {
close OUT;
return 1;
}
my $x = $self->TicketObj->FirstCustomFieldValue($cfx->id);
require Data::Dumper;
print OUT “10: [$x]\n”;
my $CustomFieldValues=$self->TicketObj->CustomFieldValues(‘worktime-a’);
my @x;
while (my $CustomFieldValue = $CustomFieldValues->Next) {
push @x, $CustomFieldValue->Content;
}
print OUT “11: [”.join(", “, @x).”.\n";
close OUT;
return 1;

– action

basically, despite the fact that i have set worktime-a for this ticket
to 123, all i got is undef.
can anybody of you point me to working way of getting ticket’s custom
field value?

best regards

depesz

hubert lubaczewski
Network Operations Center
Eo Networks Sp. z o.o.

signature.asc (189 Bytes)

May be you can share relevant output from ‘/tmp/scrip.test’;

hubert lubaczewski wrote:

hi
i’m getting kind of desperate.
i tried nearly everything, yet i can’t succed.
i’m using rt 3.0.6, and my final scrip action looks like:

– action
open(OUT, “>”, “/tmp/scrip.test”);

my @a = $self->TicketObj->FirstCustomFieldValue(‘worktime-a’);
FirstCustomFieldValue return scalar

require Data::Dumper;
print OUT "7: " . Data::Dumper::Dumper(@a);

my $cfx = new RT::CustomField( $self->TransactionObj->CreatorObj );
print OUT “8: $cfx\n”;
($id,$msg) = $cf->LoadByNameAndQueue (‘Name’=>‘worktime-a’, ‘Queue’ => $self->TicketObj->QueueObj->Id);
I don’t remeber when it was fixed(somwhere arounf 3.0.7-10), but this
can be broken if ‘worktime-a’ is global field.

print OUT “9: $id | $msg\n”;
if (! $id) {
($id,$msg) = $cf->LoadByNameAndQueue (‘Name’=>‘worktime-a’, ‘Queue’ => 0);
print OUT “9a: $id | $msg\n”;
}
unless ($id) {
close OUT;
return 1;
}
my $x = $self->TicketObj->FirstCustomFieldValue($cfx->id);
require Data::Dumper;
print OUT “10: [$x]\n”;
my $CustomFieldValues=$self->TicketObj->CustomFieldValues(‘worktime-a’);
my @x;
while (my $CustomFieldValue = $CustomFieldValues->Next) {
push @x, $CustomFieldValue->Content;
}
print OUT “11: [”.join(“, “, @x).”.\n”;
close OUT;
return 1;

– action

basically, despite the fact that i have set worktime-a for this ticket
to 123, all i got is undef.
can anybody of you point me to working way of getting ticket’s custom
field value?
should be all. I don’t see more errors.