OnCreateAutoReplyException

From Request Tracker Wiki
Jump to navigation Jump to search

Purpose: We have emails coming in from automated systems and we don't want emails going out. While we are using this on the Create - AutoReply scrip it can used on any other scrip where you want to create an exception list.

Author: macnlos AT gmail DOT com - I'm on the RT Users List

Description: Autoreply on Create with Exceptions

Condition: User Defined

Action: Autoreply to Requestors

Template: Global template: Autoreply

State: TransactionCreate

Custom Condition:

 my @exceptionList = ('joe@goblow.com',
                      'fred@quarry.com',
                      'scooby@mysterymachine.com');
 my $transactionType = $self->TransactionObj->Type;
 my $ticketRequestor = lc($self->TicketObj->RequestorAddresses);
 if ($transactionType eq 'Create') {
   return if grep { $ticketRequestor eq lc($_) } @exceptionList;
   return 1;
 }
 return;


Code Explanation:

We want to test if the transaction type is "Create" and the email address of the requestor is not in the exception list. The variable @exceptionList is where you can add the email addresses you want to exclude.

The first IF statement tests to see if this is a "Create" action and if it is it then proceeds. Otherwise it skips everything and just returns which is the equivalent of saying false.

The grep processes the @exceptionList array and compares it to the requestor email address of the ticket. If it finds a match then it simply returns. If it goes through the entire array without a match then you want to send an email so it returns a true value.

The "lc" functions in the script makes sure that everything is switched to lower-case to prevent "YOU@there" eq "you@THERE" from returning false.