Scrip for escalating priority based on to address from header

I’ve read up on priorities, but nothing I’ve seen quite fits my need. We
have two email addresses that both go to the same queue, an alert email
and a support email. The alert email also SMS’s my mobile phone. I’d
like to have RT check the to: address from the header and set anything
to the alert email to a high priority. Then I can do things like a cron
to check for untouched emails with a high priority and alert us.

I’ve approached this with a user defined scrip in the server queue:

Custom condition: return 1;

Custom action prep code: return 1;

Custom action cleanup code:

package RT::User;

my $to = $Ticket->Transactions->First->Message->First->GetHeader(‘To’);
if $to = (‘xxx-alert@.*.?tivo.com’)
{
$self->TicketObj->SetPriority(98);
}
return 1;

When opening a new ticket, I see in rt.log:
[Wed Jan 30 18:56:16 2008] [error]: Scrip 16 Commit failed: Global
symbol “$to” requires explicit package name at (eval 2242) line 3.
Global symbol “$Ticket” requires explicit package name at (eval 2242)
line 3.
syntax error at (eval 2242) line 4, near "if $to "
Global symbol “$to” requires explicit package name at (eval 2242) line
4.
(/usr/lib/rt/RT/Action/UserDefined.pm:81)

Obviously, I’m doing something very wrong, but I’m not clear what. Could
someone proofread this and let me know where I’ve gone wrong? Thanks!

Kimberly McKinnis
System Operations Engineer
Service Provider Division, TiVo Inc
408-519-9607

Why do you have a package statement?

And $Ticket should be $self->TicketObj.On 1/30/08, Kimberly McKinnis kmckinnis@tivo.com wrote:

I’ve read up on priorities, but nothing I’ve seen quite fits my need. We
have two email addresses that both go to the same queue, an alert email and
a support email. The alert email also SMS’s my mobile phone. I’d like to
have RT check the to: address from the header and set anything to the alert
email to a high priority. Then I can do things like a cron to check for
untouched emails with a high priority and alert us.

I’ve approached this with a user defined scrip in the server queue:

Custom condition: return 1;

Custom action prep code: return 1;

Custom action cleanup code:

package RT::User;

my $to = $Ticket->Transactions->First->Message->First->GetHeader(‘To’);
if $to = (‘xxx-alert@.*.?tivo.com’)
{
$self->TicketObj->SetPriority(98);
}
return 1;

When opening a new ticket, I see in rt.log:
[Wed Jan 30 18:56:16 2008] [error]: Scrip 16 Commit failed: Global symbol
“$to” requires explicit package name at (eval 2242) line 3.

Global symbol “$Ticket” requires explicit package name at (eval 2242) line
3.
syntax error at (eval 2242) line 4, near "if $to "
Global symbol “$to” requires explicit package name at (eval 2242) line 4.
(/usr/lib/rt/RT/Action/UserDefined.pm:81)

Obviously, I’m doing something very wrong, but I’m not clear what. Could
someone proofread this and let me know where I’ve gone wrong? Thanks!

~~
Kimberly McKinnis
System Operations Engineer
Service Provider Division, TiVo Inc
408-519-9607


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Because I have no idea what I’m doing. Without, I still receive errors:

[Wed Jan 30 20:17:14 2008] [error]: Scrip 16 Commit failed: Global
symbol “$to” requires explicit package name at (eval 2305) line 1.
Global symbol “$Ticket” requires explicit package name at (eval 2305)
line 1.
syntax error at (eval 2305) line 2, near "if $to "
Global symbol “$to” requires explicit package name at (eval 2305) line
2.
(/usr/lib/rt/RT/Action/UserDefined.pm:81)From: Todd Chapman [mailto:todd@chaka.net]
Sent: Wednesday, January 30, 2008 11:58 AM
To: Kimberly McKinnis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
address from header

Why do you have a package statement?

And $Ticket should be $self->TicketObj.

Kimberly,

I would starting by picking up a copy of Learning Perl. If you don’t know
basic Perl syntax there is no way you will be able to write RT scrips. Try:

if ($to =~ /xxx-alert@.*.?tivo.com/) {
{
$self->TicketObj->SetPriority(98);
}

I’ll write it for you if you send me an HD Tivo. :wink:

-ToddOn 1/30/08, Kimberly McKinnis kmckinnis@tivo.com wrote:

Because I have no idea what I’m doing. Without, I still receive errors:

[Wed Jan 30 20:17:14 2008] [error]: Scrip 16 Commit failed: Global symbol
“$to” requires explicit package name at (eval 2305) line 1.
Global symbol “$Ticket” requires explicit package name at (eval 2305) line
1.
syntax error at (eval 2305) line 2, near "if $to "
Global symbol “$to” requires explicit package name at (eval 2305) line 2.
(/usr/lib/rt/RT/Action/UserDefined.pm:81)


From: Todd Chapman [mailto:todd@chaka.net]
Sent: Wednesday, January 30, 2008 11:58 AM
To: Kimberly McKinnis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
address from header

Why do you have a package statement?

And $Ticket should be $self->TicketObj.

On 1/30/08, Kimberly McKinnis kmckinnis@tivo.com wrote:

I’ve read up on priorities, but nothing I’ve seen quite fits my need.
We have two email addresses that both go to the same queue, an alert email
and a support email. The alert email also SMS’s my mobile phone. I’d like to
have RT check the to: address from the header and set anything to the alert
email to a high priority. Then I can do things like a cron to check for
untouched emails with a high priority and alert us.

I’ve approached this with a user defined scrip in the server queue:

Custom condition: return 1;

Custom action prep code: return 1;

Custom action cleanup code:

package RT::User;

my $to = $Ticket->Transactions->First->Message->First->GetHeader(‘To’);
if $to = (‘xxx-alert@.*.?tivo.com’)
{
$self->TicketObj->SetPriority(98);
}
return 1;

When opening a new ticket, I see in rt.log:
[Wed Jan 30 18:56:16 2008] [error]: Scrip 16 Commit failed: Global
symbol “$to” requires explicit package name at (eval 2242) line 3.

Global symbol “$Ticket” requires explicit package name at (eval 2242)
line 3.
syntax error at (eval 2242) line 4, near "if $to "
Global symbol “$to” requires explicit package name at (eval 2242) line
4.
(/usr/lib/rt/RT/Action/UserDefined.pm:81)

Obviously, I’m doing something very wrong, but I’m not clear what. Could
someone proofread this and let me know where I’ve gone wrong? Thanks!

~~
Kimberly McKinnis
System Operations Engineer
Service Provider Division, TiVo Inc
408-519-9607


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Sadly, I’m not cool enough to get you a free TiVo. Mine wasn’t even free
:stuck_out_tongue:

I have Learning Perl, I’m just floundering and it’s all starting to look
the same

Condition: on create
Action: User Defined
Templayte: Global template: Blank
Stage: TransactionCreate

my $to =
$self->TicketObj->Transactions->First->Message->First->GetHeader(‘To’);
if ($to =~/xx-alert@.*.?tivo.com/)
{
$self->TicketObj->SetPriority(98);
}
return 1;

It doesn’t error, but it seems to be ignored entirely. I used ‘my’, as
the global variable was throwing errors about global symbol requiring an
explicit package name. Perhaps it’s working and not parsing right?From: Todd Chapman [mailto:todd@chaka.net]
Sent: Wednesday, January 30, 2008 12:23 PM
To: Kimberly McKinnis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
address from header

Kimberly,

I would starting by picking up a copy of Learning Perl. If you don’t
know basic Perl syntax there is no way you will be able to write RT
scrips. Try:

if ($to =~ /xxx-alert@.*.?tivo.com/) {
{
$self->TicketObj->SetPriority(98);
}

I’ll write it for you if you send me an HD Tivo. :wink:

-Todd

At Wednesday 1/30/2008 06:06 PM, Kimberly McKinnis wrote:

my $to =
$self->TicketObj->Transactions->First->Message->First->GetHeader(‘To’);
if ($to =~/xx-alert@.*.?tivo.com/)
{
$self->TicketObj->SetPriority(98);
}
return 1;

It doesn’t error, but it seems to be ignored entirely. I used ‘my’,
as the global variable was throwing errors about global symbol
requiring an explicit package name. Perhaps it’s working and not parsing right?

Kimberley,

A very useful tool is the RT logger. If you put logging statements in
your code, they’ll show up in the RT log, so you can see if your code
is being executed, examine variables etc. The code looks like this:

$RT::Logger->debug(“I am here”);

or

$RT::Logger->debug("Ticket number is: " . $self->TicketObj->id );

Steve

Perfect! I’m running logging in debug mode, but it’s not enough… I
wanted to know what it thought $to was.

Thank you!From: Stephen Turner [mailto:sturner@MIT.EDU]
Sent: Thursday, January 31, 2008 8:00 AM
To: Kimberly McKinnis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
address from header

At Wednesday 1/30/2008 06:06 PM, Kimberly McKinnis wrote:

my $to =
$self->TicketObj->Transactions->First->Message->First->GetHeader(‘To’);
if ($to =~/xx-alert@.*.?tivo.com/)
{
$self->TicketObj->SetPriority(98);
}
return 1;

It doesn’t error, but it seems to be ignored entirely. I used ‘my’, as
the global variable was throwing errors about global symbol requiring
an explicit package name. Perhaps it’s working and not parsing right?

Kimberley,

A very useful tool is the RT logger. If you put logging statements in
your code, they’ll show up in the RT log, so you can see if your code is
being executed, examine variables etc. The code looks like this:

$RT::Logger->debug(“I am here”);

or

$RT::Logger->debug("Ticket number is: " . $self->TicketObj->id );

Steve

$RT::Logger->debug(“To email was: $to”);

returns

[Thu Jan 31 19:20:07 2008] [debug]: To email was: ((eval 2211):3)

Clearly I’m not parsing the header right :frowning: I can only find references
to GetHeader in Attachment_Overlay.pm…

[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Kimberly
McKinnisSent: Thursday, January 31, 2008 11:03 AM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
addressfrom header

Perfect! I’m running logging in debug mode, but it’s not enough… I
wanted to know what it thought $to was.

Thank you!

From: Stephen Turner [mailto:sturner@MIT.EDU]
Sent: Thursday, January 31, 2008 8:00 AM
To: Kimberly McKinnis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
address from header

At Wednesday 1/30/2008 06:06 PM, Kimberly McKinnis wrote:

my $to =
$self->TicketObj->Transactions->First->Message->First->GetHeader(‘To’);
if ($to =~/xx-alert@.*.?tivo.com/)
{
$self->TicketObj->SetPriority(98);
}
return 1;

It doesn’t error, but it seems to be ignored entirely. I used ‘my’, as
the global variable was throwing errors about global symbol requiring
an explicit package name. Perhaps it’s working and not parsing right?

Kimberley,

A very useful tool is the RT logger. If you put logging statements in
your code, they’ll show up in the RT log, so you can see if your code is
being executed, examine variables etc. The code looks like this:

$RT::Logger->debug(“I am here”);

or

$RT::Logger->debug("Ticket number is: " . $self->TicketObj->id );

Steve

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com Commercial support:
sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

For anyone interested, it seems the correct line is:

my $to = $self->TransactionObj->Attachments->First->GetHeader(‘To’);

Everything works as expected now.

[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Kimberly
McKinnisSent: Thursday, January 31, 2008 11:31 AM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on
toaddressfrom header

$RT::Logger->debug(“To email was: $to”);

returns

[Thu Jan 31 19:20:07 2008] [debug]: To email was: ((eval 2211):3)

Clearly I’m not parsing the header right :frowning: I can only find references
to GetHeader in Attachment_Overlay.pm…

From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Kimberly
McKinnis
Sent: Thursday, January 31, 2008 11:03 AM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
addressfrom header

Perfect! I’m running logging in debug mode, but it’s not enough… I
wanted to know what it thought $to was.

Thank you!

From: Stephen Turner [mailto:sturner@MIT.EDU]
Sent: Thursday, January 31, 2008 8:00 AM
To: Kimberly McKinnis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip for escalating priority based on to
address from header

At Wednesday 1/30/2008 06:06 PM, Kimberly McKinnis wrote:

my $to =
$self->TicketObj->Transactions->First->Message->First->GetHeader(‘To’);
if ($to =~/xx-alert@.*.?tivo.com/)
{
$self->TicketObj->SetPriority(98);
}
return 1;

It doesn’t error, but it seems to be ignored entirely. I used ‘my’, as
the global variable was throwing errors about global symbol requiring
an explicit package name. Perhaps it’s working and not parsing right?

Kimberley,

A very useful tool is the RT logger. If you put logging statements in
your code, they’ll show up in the RT log, so you can see if your code is
being executed, examine variables etc. The code looks like this:

$RT::Logger->debug(“I am here”);

or

$RT::Logger->debug("Ticket number is: " . $self->TicketObj->id );

Steve

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com Commercial support:
sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com Commercial support:
sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com