[rt-users] Custom Condition based on Transaction Custom Field value
MP
marton.peter at gmail.com
Wed Mar 9 16:14:07 EST 2005
Hi Steve!
Thanks for the help, it was what i needed!
I found out the obvious. In Transaction_Overlay.pm :
>>>
sub CustomFieldValues {
my $self = shift;
my $field = shift;
(...)
return $self->SUPER::CustomFieldValues($field);
<<<
Without a $field value it returns nothing! So i gave him a
CustomField->Name:
>>>
my $CustomFieldValues=$tr->CustomFieldValues("nyomi");
<<<
And it worked! :D
But if i do it in a scrip condition it gives me nothing:
>>>
my $Tr = $self->TransactionObj;
my $CustomFieldValues=$Tr->CustomFieldValues("nyomi");
$RT::Logger->error( "Warning!Self destruct sequence has been initiated!");
$RT::Logger->error( "Warp core overload in 4 minutes 55 seconds." );
while (my $CustomFieldValue = $CustomFieldValues->Next) {
$RT::Logger->error( ".CFV. ".$CustomFieldValue->Content );
};
$RT::Logger->error( "There will be no further audio warnings!" );
return (1);
<<<
Mar 9 21:13:39 linux RT: Warning!Self destruct sequence has been
initiated! ((eval 1365):3)
Mar 9 21:13:39 linux RT: Warp core overload in 4 minutes 55 seconds.
((eval 1365):4)
Mar 9 21:13:39 linux RT: There will be no further audio warnings!
((eval 1365):8)
I also tried to extract the transaction from the TicketObj... but no luck:
>>>
my $CFV;
my $t = $self->TicketObj;
$RT::Logger->error( "Req=".$t->RequestorAddresses);
my $trs = $t->Transactions;
while (my $tr = $trs->Next)
{
my $CustomFieldValues = $tr->CustomFieldValues("nyomi");
my $CustomFieldValue = $CustomFieldValues->Next;
my $CFV = $CustomFieldValue->Content;
};
$RT::Logger->error( "CFV=".$CFV );
return(1);
<<<
Mar 9 21:58:54 linux RT: About to think about scrips for transaction #1443
Mar 9 21:58:54 linux RT: About to prepare scrips for transaction #1443
Mar 9 21:58:55 linux RT: Found 5 scrips
Mar 9 21:58:55 linux RT: Req=root at localhost ((eval 1465):3)
Mar 9 21:58:55 linux RT: Scrip 17 IsApplicable failed: Can't call
method "Content" on an undefined value at (eval 1465) line 9. Stack:
[(eval 1465):9] [/opt/rt3/lib/RT/ScripCondition_Overlay.pm:219]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:438]
[/opt/rt3/lib/RT/Scrips_Overlay.pm:228]
[/opt/rt3/lib/RT/Transaction_Overlay.pm:160]
[/opt/rt3/lib/RT/Record.pm:1373]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:2369]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:2255]
[/opt/rt3/lib/RT/Interface/Web.pm:469]
[/opt/rt3/share/html/Ticket/Display.html:135]
[/opt/rt3/share/html/Ticket/Update.html:211]
[/opt/rt3/share/html/autohandler:215]
(/opt/rt3/lib/RT/Condition/UserDefined.pm:67)
Mar 9 21:58:56 linux RT: About to commit scrips for transaction #1443
So we are where we started... :( $CustomFieldValues returns undef...
I paste here the only working example... i don't understand the
difference between the two Ticket objects... One in a perl script...
another in a scrip?
[I thought it was a seecustomfield right problem, so i added this right
to root - above of superuser :) but it didn't help...]
>>>
#!/usr/bin/perl -I/opt/rt3/lib
use RT;
RT::LoadConfig;
RT::Init;
my $u = RT::User->new($RT::SystemUser);
$u->Load("root");
my $t = RT::Ticket->new($RT::SystemUser);
$t->Load("98");
my $trs = $t->Transactions;
while (my $tr = $trs->Next)
{
print $tr->Subject;
print "\n";
my $CustomFieldValues=$tr->CustomFieldValues("nyomi");
while (my $CustomFieldValue = $CustomFieldValues->Next)
{
print "\t".$CustomFieldValue->Content;
print "\n";
};
};
<<<
Stephen Turner írta:
> Try passing $RT::SystemUser (instead of $u ) to RT::Ticket->new.
>
> Steve
>
More information about the rt-users
mailing list