[rt-users] Custom Condition based on Transaction Custom Field value

MP marton.peter at gmail.com
Tue Mar 8 17:35:11 EST 2005


Stephen Turner írta:

> Is your RT configured to log errors? If so, that would indicate there 
> are no values for the CF for the transaction. Have you played around 
> with perl scripts that access the RT API? They're great for pulling 
> out bits of code like this and using the perl debugger to step through 
> and get a better idea of what's going on.


Yes, it's logs errors, and i wrote something in the CF.
My scrip condition:

my $Ticket = $self->TransactionObj;
my $CustomFieldValues=$Ticket->CustomFieldValues;
$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);

And the log for a transaction:

Mar  8 21:31:55 linux RT: About to think about scrips for transaction #1409
Mar  8 21:31:55 linux RT: About to prepare scrips for transaction #1409
Mar  8 21:31:55 linux RT: Found 5 scrips
Mar  8 21:31:56 linux RT: Warning!Self destruct sequence has been 
initiated! ((eval 1201):3)
Mar  8 21:31:56 linux RT: Warp core overload in 4 minutes 55 seconds. 
((eval 1201):4)
Mar  8 21:31:56 linux RT: There will be no further audio warnings! 
((eval 1201):8)
Mar  8 21:31:56 linux RT: About to commit scrips for transaction #1409
Mar  8 21:31:56 linux RT: 
<rt-3.4.1-98-1409-8.16.6756791385311 at cc.mailmax.hu> #98/1409 - Scrip 8  
(/opt/rt3/lib/RT/Action/SendEmail.pm:235)
Mar  8 21:31:56 linux RT: 
<rt-3.4.1-98-1409-8.16.6756791385311 at cc.mailmax.hu> No recipients found. 
Not sending.  (/opt/rt3/lib/RT/Action/SendEmail.pm:247)
Mar  8 21:31:56 linux RT: 
<rt-3.4.1-98-1409-9.8.78181131431681 at cc.mailmax.hu> #98/1409 - Scrip 9  
(/opt/rt3/lib/RT/Action/SendEmail.pm:235)
Mar  8 21:31:59 linux RT: About to think about scrips for transaction #1410
Mar  8 21:31:59 linux RT: 
<rt-3.4.1-98-1409-9.8.78181131431681 at cc.mailmax.hu> sent To:  Cc: 
marton.peter at gmail.com Bcc:  (/opt/rt3/lib/RT/Action/SendEmail.pm:295)

In my mind it means that the first call for 
$self->TransactionObj->$CustomFieldValues->Next returns undef as it 
would no Transaction CF be there. Is it so?

I made a small script, but it gives an error... :( Should i initialize 
something? (self destruct maybe? :))

#!/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($u);
$t->Load("98");
my $trs = $t->Transactions;

Mar  9 00:11:46 linux RT:  at /opt/rt3/lib/RT/Ticket_Overlay.pm line 
3564      RT::Ticket::HasRight('RT::Ticket=HASH(0x8ec30d4)', 
'Principal', 0, 'No object mapping for field', 'Right', 'ShowTicket') 
called at /opt/rt3/lib/RT/Ticket_Overlay.pm line 3532   
RT::Ticket::CurrentUserHasRight('RT::Ticket=HASH(0x8ec30d4)', 
'ShowTicket') called at /opt/rt3/lib/RT/Ticket_Overlay.pm line 
3595       RT::Ticket::Transactions('RT::Ticket=HASH(0x8ec30d4)') called 
at ./rtx line 9  (/opt/rt3/lib/RT.pm:277)
Mar  9 00:11:46 linux RT: Principal attrib undefined for 
Ticket::HasRight (/opt/rt3/lib/RT/Ticket_Overlay.pm:3565)

Thanks for the help!



More information about the rt-users mailing list