Error with custom scrip action

Hi everyone,
I’m running rt 3.4.0 on apache 1.3 with mod_perl 1, perl 5.8.4, mysql 4.19. I’m trying to create a custom scrip action to add adminCc’s to a ticket based on the custom field selection and a change of owner.
The scrip i’m using is given below.

Scrip condition: On owner change
scrip action: user defined
template:global template blank

custom action preparation code: return 1;
custom action cleanup code:

my $Ticket= RT::Ticket->new ($RT::SystemUser);
my $admincclist = $Ticket->AdminCc;
my $cfValue = $Ticket->FirstCustomFieldValue(‘Region’);
if ($cfValue =~/Region East/i && $self->TransactionObj->Type eq “Set” && $self->TransactionObj->Field eq “Owner”)
{
$user->LoadByEmail(‘browna@tosoft.com’);
$admincclist->AddMember($user->Id);
}
elsif ($cfValue =~/Region West/i && $self->TransactionObj->Type eq “Set” && $self->TransactionObj->Field eq “Owner”)
{
$user->LoadByEmail(‘charlesd@tosoft.com’);
$admincclist->AddMember($user->Id);
}
elsif ($cfValue =~/Region North/i && $self->TransactionObj->Type eq “Set” && $self->TransactionObj->Field eq “Owner”)
{
$user->LoadByEmail(‘tolu@tosoft.com’);
$admincclist->AddMember($user->Id);
}
else
{
return 0;
}

But i get the following error in the log. Pls, can someone help me out. Thanks.

(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Thu Feb 24 14:35:15 2005] [error]: Template parsing error: Can’t call method “TicketObj” on an undefined value at template line 8.
Stack:
[template:8]
[/opt/rt3/lib/RT/Template_Overlay.pm:416]
[/opt/rt3/lib/RT/Template_Overlay.pm:340]
[/opt/rt3/lib/RT/Action/SendEmail.pm:112]
[/opt/rt3/lib/RT/Action/Notify.pm:65]
[/opt/rt3/lib/RT/ScripAction_Overlay.pm:220]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:477]
[/opt/rt3/lib/RT/Scrips_Overlay.pm:235]
[/opt/rt3/lib/RT/Transaction_Overlay.pm:160]
[/opt/rt3/lib/RT/Record.pm:1373]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:2997]
[/opt/rt3/lib/RT/Interface/Web.pm:1063]
[/opt/rt3/share/html/Ticket/Display.html:140]
[/opt/rt3/share/html/Ticket/Update.html:211]
[/opt/rt3/share/html/autohandler:215]
(/opt/rt3/lib/RT/Template_Overlay.pm:412)
[Thu Feb 24 14:35:15 2005] [error]: error: unexpected end of header
(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Thu Feb 24 14:35:15 2005] [debug]: About to commit scrips for transaction #2044 (/opt/rt3/lib/RT/Transaction_Overlay.pm:167)
[Thu Feb 24 14:35:15 2005] [crit]: RT::Principal=HASH(0x9d3b6f0) HasRight called with no valid object (/opt/rt3/lib/RT/Principal_Overlay.pm:293)
root@0[log]# tail --lines=100 rt.log
(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Thu Feb 24 14:35:13 2005] [debug]: About to think about scrips for transaction #2043 (/opt/rt3/lib/RT/Transaction_Overlay.pm:154)
[Thu Feb 24 14:35:13 2005] [debug]: About to prepare scrips for transaction #2043 (/opt/rt3/lib/RT/Transaction_Overlay.pm:158)
[Thu Feb 24 14:35:13 2005] [debug]: Found 3 scrips (/opt/rt3/lib/RT/Scrips_Overlay.pm:354)
[Thu Feb 24 14:35:14 2005] [error]: Template parsing error: Can’t call method “TicketObj” on an undefined value at template line 8.
Stack:
[template:8]
[/opt/rt3/lib/RT/Template_Overlay.pm:416]
[/opt/rt3/lib/RT/Template_Overlay.pm:340]
[/opt/rt3/lib/RT/Action/SendEmail.pm:112]
[/opt/rt3/lib/RT/Action/Notify.pm:65]
[/opt/rt3/lib/RT/ScripAction_Overlay.pm:220]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:477]
[/opt/rt3/lib/RT/Scrips_Overlay.pm:235]
[/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:2302]
[/opt/rt3/lib/RT/Interface/Web.pm:478]
[/opt/rt3/share/html/Ticket/Display.html:134]
[/opt/rt3/share/html/Ticket/Update.html:211]
[/opt/rt3/share/html/autohandler:215]
(/opt/rt3/lib/RT/Template_Overlay.pm:412)
[Thu Feb 24 14:35:14 2005] [error]: error: unexpected end of header
(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Thu Feb 24 14:35:14 2005] [error]: Template parsing error: Can’t call method “TicketObj” on an undefined value at template line 8.
Stack:
[template:8]
[/opt/rt3/lib/RT/Template_Overlay.pm:416]
[/opt/rt3/lib/RT/Template_Overlay.pm:340]
[/opt/rt3/lib/RT/Action/SendEmail.pm:112]
[/opt/rt3/lib/RT/Action/Notify.pm:65]
[/opt/rt3/lib/RT/ScripAction_Overlay.pm:220]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:477]
[/opt/rt3/lib/RT/Scrips_Overlay.pm:235]
[/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:2302]
[/opt/rt3/lib/RT/Interface/Web.pm:478]
[/opt/rt3/share/html/Ticket/Display.html:134]
[/opt/rt3/share/html/Ticket/Update.html:211]
[/opt/rt3/share/html/autohandler:215]
(/opt/rt3/lib/RT/Template_Overlay.pm:412)
[Thu Feb 24 14:35:14 2005] [error]: error: unexpected end of header
(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Thu Feb 24 14:35:14 2005] [debug]: About to commit scrips for transaction #2043 (/opt/rt3/lib/RT/Transaction_Overlay.pm:167)
[Thu Feb 24 14:35:14 2005] [debug]: About to think about scrips for transaction #2044 (/opt/rt3/lib/RT/Transaction_Overlay.pm:154)
[Thu Feb 24 14:35:15 2005] [debug]: About to prepare scrips for transaction #2044 (/opt/rt3/lib/RT/Transaction_Overlay.pm:158)
[Thu Feb 24 14:35:15 2005] [debug]: Found 3 scrips (/opt/rt3/lib/RT/Scrips_Overlay.pm:354)
[Thu Feb 24 14:35:15 2005] [error]: Template parsing error: Can’t call method “TicketObj” on an undefined value at template line 8.
Stack:
[template:8]
[/opt/rt3/lib/RT/Template_Overlay.pm:416]
[/opt/rt3/lib/RT/Template_Overlay.pm:340]
[/opt/rt3/lib/RT/Action/SendEmail.pm:112]
[/opt/rt3/lib/RT/Action/Notify.pm:65]
[/opt/rt3/lib/RT/ScripAction_Overlay.pm:220]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:477]
[/opt/rt3/lib/RT/Scrips_Overlay.pm:235]
[/opt/rt3/lib/RT/Transaction_Overlay.pm:160]
[/opt/rt3/lib/RT/Record.pm:1373]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:2997]
[/opt/rt3/lib/RT/Interface/Web.pm:1063]
[/opt/rt3/share/html/Ticket/Display.html:140]
[/opt/rt3/share/html/Ticket/Update.html:211]
[/opt/rt3/share/html/autohandler:215]
(/opt/rt3/lib/RT/Template_Overlay.pm:412)
[Thu Feb 24 14:35:15 2005] [error]: error: unexpected end of header
(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Thu Feb 24 14:35:15 2005] [error]: Template parsing error: Can’t call method “TicketObj” on an undefined value at template line 8.
Stack:
[template:8]
[/opt/rt3/lib/RT/Template_Overlay.pm:416]
[/opt/rt3/lib/RT/Template_Overlay.pm:340]
[/opt/rt3/lib/RT/Action/SendEmail.pm:112]
[/opt/rt3/lib/RT/Action/Notify.pm:65]
[/opt/rt3/lib/RT/ScripAction_Overlay.pm:220]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:477]
[/opt/rt3/lib/RT/Scrips_Overlay.pm:235]
[/opt/rt3/lib/RT/Transaction_Overlay.pm:160]
[/opt/rt3/lib/RT/Record.pm:1373]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:2997]
[/opt/rt3/lib/RT/Interface/Web.pm:1063]
[/opt/rt3/share/html/Ticket/Display.html:140]
[/opt/rt3/share/html/Ticket/Update.html:211]
[/opt/rt3/share/html/autohandler:215]
(/opt/rt3/lib/RT/Template_Overlay.pm:412)
[Thu Feb 24 14:35:15 2005] [error]: error: unexpected end of header
(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Thu Feb 24 14:35:15 2005] [debug]: About to commit scrips for transaction #2044 (/opt/rt3/lib/RT/Transaction_Overlay.pm:167)
[Thu Feb 24 14:35:15 2005] [crit]: RT::Principal=HASH(0x9d3b6f0) HasRight called with no valid object (/opt/rt3/lib/RT/Principal_Overlay.pm:293)

ALL-NEW Yahoo! Messenger - all new features - even more fun!

Hi everyone,
I’m running rt 3.4.0 on apache 1.3 with mod_perl 1, perl 5.8.4, mysql 4.19.
I’m trying to create a custom scrip action to add adminCc’s to a ticket
based on the custom field selection and a change of owner.
The scrip i’m using is given below.

Here’s an example from one of mine:

Description: AddWatcherFoo
Condition: User defined
Custom Condition:

return undef unless ($self->TransactionObj->Type eq “Create”);
return undef unless
($self->TicketObj->FirstCustomFieldValue(‘MyCustomField’) =~
/my_match_value/i);
return 1;

Action: User defined
Custom action prep:

my ($status, $msg) = $self->TicketObj->AddWatcher(Type => ‘Cc’, Email
=> "foo@example.com" );
return 1;

Custom action cleanup:

return 1;

Stage: TransactionCreate
Template: Global Template: Blank

Andy Harrison

Thanks Andy for the scrip, I created the scrip as follows but still got the following error, pls can u help me decode this. I don’t know why I’m getting this error “Can’t call method “TicketObj” on an undefined value” . Pls, can anyone help out:

My Scrip is given below:

Description:AddWatcherRegionEast
Custom Condition: user defined

return undef unless ($self->TransactionObj->Type eq “Create”);
return undef unless ($self->TicketObj->FirstCustomFieldValue(‘Region’) =~ /RegionEast/i);
return 1;

Custom action prep:

my ($status, $msg) = $self->TicketObj->AddWatcher(Type => ‘Cc’, Email => "tola@net2g.net" );
return 1;

custom action cleanup code:
return 1;

The error i got is:

[Mon Feb 28 13:14:49 2005] [info]: Successful login for customercare from 10.50.1.107 (/opt/rt3/share/html/autohandler:197)
[Mon Feb 28 13:15:19 2005] [debug]: About to think about scrips for transaction #2316 (/opt/rt3/lib/RT/Transaction_Overlay.pm:154)
[Mon Feb 28 13:15:19 2005] [debug]: About to think about scrips for transaction #2317 (/opt/rt3/lib/RT/Transaction_Overlay.pm:154)
[Mon Feb 28 13:15:19 2005] [debug]: About to think about scrips for transaction #2318 (/opt/rt3/lib/RT/Transaction_Overlay.pm:154)
[Mon Feb 28 13:15:19 2005] [debug]: About to think about scrips for transaction #2319 (/opt/rt3/lib/RT/Transaction_Overlay.pm:154)
[Mon Feb 28 13:15:20 2005] [debug]: About to think about scrips for transaction #2320 (/opt/rt3/lib/RT/Transaction_Overlay.pm:154)
[Mon Feb 28 13:15:20 2005] [debug]: About to prepare scrips for transaction #2320 (/opt/rt3/lib/RT/Transaction_Overlay.pm:158)
[Mon Feb 28 13:15:20 2005] [debug]: Found 2 scrips (/opt/rt3/lib/RT/Scrips_Overlay.pm:354)
[Mon Feb 28 13:15:20 2005] [error]: Template parsing error: Can’t call method “TicketObj” on an undefined value at template line 8.
Stack:
[template:8]
[/opt/rt3/lib/RT/Template_Overlay.pm:416]
[/opt/rt3/lib/RT/Template_Overlay.pm:340]
[/opt/rt3/lib/RT/Action/SendEmail.pm:112]
[/opt/rt3/lib/RT/Action/Notify.pm:65]
[/opt/rt3/lib/RT/ScripAction_Overlay.pm:220]
[/opt/rt3/lib/RT/Scrip_Overlay.pm:477]
[/opt/rt3/lib/RT/Scrips_Overlay.pm:235]
[/opt/rt3/lib/RT/Transaction_Overlay.pm:160]
[/opt/rt3/lib/RT/Record.pm:1373]
[/opt/rt3/lib/RT/Ticket_Overlay.pm:720]
[/opt/rt3/lib/RT/Interface/Web.pm:385]
[/opt/rt3/share/html/Ticket/Display.html:101]
[/opt/rt3/share/html/Ticket/Create.html:288]
[/opt/rt3/share/html/autohandler:215]
(/opt/rt3/lib/RT/Template_Overlay.pm:412)
[Mon Feb 28 13:15:20 2005] [error]: error: unexpected end of header
(/opt/rt3/lib/RT/Template_Overlay.pm:366)
[Mon Feb 28 13:15:20 2005] [debug]: About to commit scrips for transaction #2320 (/opt/rt3/lib/RT/Transaction_Overlay.pm:167)
[Mon Feb 28 13:15:20 2005] [info]: Ticket 189 created in queue ‘General’ by customercare (/opt/rt3/lib/RT/Ticket_Overlay.pm:730)

Send instant messages to your online friends http://uk.messenger.yahoo.com

Description:AddWatcherRegionEast
Custom Condition: user defined

return undef unless ($self->TransactionObj->Type eq “Create”);
return undef unless ($self->TicketObj->FirstCustomFieldValue(‘Region’) =~
/RegionEast/i);
return 1;

Custom action prep:

my ($status, $msg) = $self->TicketObj->AddWatcher(Type => ‘Cc’, Email =>
"tola@net2g.net" );
return 1;

custom action cleanup code:
return 1;

The error i got is:

[Mon Feb 28 13:15:20 2005] [error]: Template parsing error: Can’t call
method “TicketObj” on an undefined value at template line 8.

It’s complaining about the template. Are you making sure to use
Blank? If so, did you modify that template?

Andy Harrison