Delete message with /Returned mail/ in the subject line on arrival

Hi, I’m trying to create a scrip with will delete a new ticket on
arrival if it has “Returned mail” in the subject line. From searching
through the mailing list archive for a while I’ve come up with
something which I think is pretty close, yet it’s not deleting these
messages.

Here is what I have:

if ($self->TicketObj->Subject =~ /Returned/) { $self->TicketObj-

SetStatus(‘deleted’); 1; } else { undef; }

I have this in the Custom condition field under Configuration >
Global > Scrips > My Delete Scrip

The scrip fields are set as follows:

Description: Delete Returned Mail
Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

I’m using RT 3.4.2.

Is my perl wrong or do I need to activate this somehow or attach it
to a template? Or do I need to put this code in "Custom action
perparation code: ??

Thank you for any help.

Romeo

Hi Romeo,

Try setting “Custom action preparation code:” to:
return 1;

This works for us. Also note that the code you have will delete any ticket with the string “Returned” in its subject. You may want to make it more specific:

if ($self->TicketObj->Subject =~ /^Returned mail/) {…}

This will delete only tickets where the first two words of the Subject are “Returned mail”.

Sincerely,
Frank Pater
DCANet

voice: 888-4-DCANET (888-432-2638)
fax: 302-426-6386On Fri, May 05, 2006 at 03:50:13PM -0400, Romeo Theriault wrote:

Hi, I’m trying to create a scrip with will delete a new ticket on
arrival if it has “Returned mail” in the subject line. From searching
through the mailing list archive for a while I’ve come up with
something which I think is pretty close, yet it’s not deleting these
messages.

Here is what I have:

if ($self->TicketObj->Subject =~ /Returned/) { $self->TicketObj-

SetStatus(‘deleted’); 1; } else { undef; }

I have this in the Custom condition field under Configuration >
Global > Scrips > My Delete Scrip

The scrip fields are set as follows:

Description: Delete Returned Mail
Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

I’m using RT 3.4.2.

Is my perl wrong or do I need to activate this somehow or attach it
to a template? Or do I need to put this code in "Custom action
perparation code: ??

Thank you for any help.

Romeo


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

We’re hiring! Come hack Perl for Best Practical:
Careers — Best Practical Solutions

Thanks Frank! That did it. I also had to move the ($self->TicketObj-

Subject =~ /^Returned mail/) {…} code into the Custom action
cleanup code: area. Then it worked.

Thanks for the tip about the regex. I have a quick question about
that though. To match the words “Returned mail” wouldn’t I have to
use a “\s” to match the space that is between the word “Returned” and
the word “mail”? or does RT use a modified version of regex?

Thanks.

RomeoOn May 5, 2006, at 4:05 PM, Frank Pater wrote:

Hi Romeo,

Try setting “Custom action preparation code:” to:
return 1;

This works for us. Also note that the code you have will delete any
ticket with the string “Returned” in its subject. You may want to
make it more specific:

if ($self->TicketObj->Subject =~ /^Returned mail/) {…}

This will delete only tickets where the first two words of the
Subject are “Returned mail”.

Sincerely,
Frank Pater
DCANet
http://www.dca.net
voice: 888-4-DCANET (888-432-2638)
fax: 302-426-6386

On Fri, May 05, 2006 at 03:50:13PM -0400, Romeo Theriault wrote:

Hi, I’m trying to create a scrip with will delete a new ticket on
arrival if it has “Returned mail” in the subject line. From searching
through the mailing list archive for a while I’ve come up with
something which I think is pretty close, yet it’s not deleting these
messages.

Here is what I have:

if ($self->TicketObj->Subject =~ /Returned/) { $self->TicketObj-

SetStatus(‘deleted’); 1; } else { undef; }

I have this in the Custom condition field under Configuration >
Global > Scrips > My Delete Scrip

The scrip fields are set as follows:

Description: Delete Returned Mail
Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

I’m using RT 3.4.2.

Is my perl wrong or do I need to activate this somehow or attach it
to a template? Or do I need to put this code in "Custom action
perparation code: ??

Thank you for any help.

Romeo


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

We’re hiring! Come hack Perl for Best Practical:
Careers — Best Practical Solutions

Thanks for the tip about the regex. I have a quick question about
that though. To match the words “Returned mail” wouldn’t I have to
use a “\s” to match the space that is between the word “Returned” and
the word “mail”? or does RT use a modified version of regex?

Literal spaces are valid within a regular expression. However, they only
match the literal space (as you would expect) rather then all whitespace
characters as the \s does.

Joshua Colson jcolson@voidgate.org