Scrip to auto-resolve a ticket based on subject

Hi all,

We get backup reports sent to our RT every night and we need to have them stored in the helpdesk, however we would like to resolve all tickets immediately which arrive for jobs that complete successfully, so that we only see the reports which require action, but can still search on the resolved successful ones if we need to.

So far I’ve created a scrip in our Backup queue which looks like this:

Condition: user defined
Action: user defined
Template: -
Stage: TransactionCreate

In custom condition I have:

my $match = “Backup Report [Successful]”;
my $t_subject = $self->TicketObj->Subject;
if ( $t_subject !~ /$match/i ) {
return 0;
}
else {
return 1;
}

In Custom action preparation code I have nothing.

In Custom action cleanup code I have:

$self->TicketObj->SetStatus( “resolved”); return 1;

I’m sure I’m missing something, my perl is REALLY not good so I hope you uys can help point out what I’m missing. Thanks for your help!

Kind Regards,

David Hooton
Managing Director
Platform Networks
www.platformnetworks.net

Hi all,

So far I’ve created a scrip in our Backup queue which looks like this:

my $match = “Backup Report [Successful]”;

First the square brackets have to be escaped. You want
"Backup Report [Successful]"

my $t_subject = $self->TicketObj->Subject;
if ( $t_subject !~ /$match/i ) {
return 0;
}
else {
return 1;
}

Also, Perl return value for true is 1 and if you want the scrip to
execute for subject matching, you’ll want to put return 1 inside the if
body.

In Custom action preparation code I have nothing.

In Custom action cleanup code I have:

$self->TicketObj->SetStatus( “resolved”); return 1;

Also I would advise you to set the action to resolve ticket
instead of user defined, since I would expect you to have a resolve
ticket available by default. Hope this helps.

Regards, Terence.


Ph: +91 (80) 4089 0000

It benefits the community if you reply/Cc to the list.

Thank you for your help Terrence…

That would be Terence with a single r.

So I’ve fixed the escaping, thankyou!

I don’t understand this however:

" Also, Perl return value for true is 1 and if you want the scrip to
execute for subject matching, you’ll want to put return 1 inside the if
body."

Inside the if block, you need to put return 1 instead of return 0. So if
the subject matches the pattern, the action is executed. In the else
part, you can have return undef.

Can you explain what I should be changing and where? I’m sorry I am very unskilled in perl.

Finally I can not find “resolve ticket” in the action list…? Is that a problem?

Never mind. It doesn’t seem to be there. Ensure you have return 1 in you
action preparation code. You can refer the wiki for a resolve ticket
scrip action:

http://wiki.bestpractical.com/view/ResolveTicket

Regards, Terence.


Ph: +91 (80) 4089 0000

Terence,

It benefits the community if you reply/Cc to the list.

Apologies - I didn’t hit reply all.

I have it working now, that wiki article helped me find my errors. For others future reference here’s what I wound up with:

Description: Auto Close Successful Backups
Condition: On Create
Action: User Defined
Template: Global Template: Blank
Stage: TransactionCreate

Custom condition:
my $match = “Backup Report [Successful]”;
my $t_subject = $self->TicketObj->Subject;
if ( $t_subject !~ /$match/i ) {
return 1;
}
else {
return 0;
}

Custom action preparation code:

return 1;

Custom action cleanup code:

$self->TicketObj->SetStatus( “resolved” );
return 1;

This seems to be working really well now, thanks to Terence for his help.

Kind Regards,

David Hooton
Managing Director
Platform Networks
www.platformnetworks.net