Scrip for auto reject email

Hello All,

We have a requirement to auto reject email with the subject line “Bulk” for the queue name “Incident report”. I have written the scrip for it … Please find the scrip below.

Custom condition:

my $match = “Bulk”;
my $t_subject = $self->TicketObj->Subject;
my $matchqueue = “Incident Reports”;
my $t_queue = $self->TicketObj->queue;
if ( $t_subject =~ /$match/i && $t_queue =~ /$matchqueue/i ) {
return 1;
}
else {
return 0;
}

Custom action preparation code:
return 1;

Custom action commit code:

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

Please someone help me in verifying the scrip

I would think the second part of this conditional is wrong - don’t you want to compare against $t_queue?

1 Like

sorry… bymistake i copied the wrong scrip …This is the correct condition for it

my $match = “Bulk”;
my $t_subject = $self->TicketObj->Subject;
my $matchqueue = “Incident Reports”;
my $t_queue = $self->TicketObj->queue;
if ( $t_subject =~ /$match/i && $t_queue =~ /$matchqueue/i ) {
return 1;
}
else {
return 0;
}

You could avoid the queue check and only apply the scrip to your incident reports queue. Also I’d add a check in the condition for the transaction type being the create transaction:

return unless $self->TranactionObj->Type eq “Create”;

To test you can create a ticket that would be rejected and watch the RT logs for any errors

1 Like