OnCreateAutoReplyException: Difference between revisions
m (3 revisions imported) |
m (formatting) |
||
Line 5: | Line 5: | ||
'''Description:''' Autoreply on Create with Exceptions | '''Description:''' Autoreply on Create with Exceptions | ||
'''Condition:''' User Defined | '''Condition:''' <code>User Defined</code> | ||
'''Action:''' Autoreply to Requestors | '''Action:''' <code>Autoreply to Requestors</code> | ||
'''Template:''' Global template: Autoreply | '''Template:''' <code>Global template: Autoreply</code> | ||
'''State:''' < | '''State:''' <code>TransactionCreate</code> | ||
'''Custom Condition:''' | '''Custom Condition:''' | ||
<source> my @exceptionList = ('joe@goblow.com', | |||
'fred@quarry.com', | 'fred@quarry.com', | ||
'scooby@mysterymachine.com'); | 'scooby@mysterymachine.com'); | ||
my $transactionType = $self->TransactionObj->Type; | |||
my $transactionType = $self- | my $ticketRequestor = lc($self->TicketObj->RequestorAddresses); | ||
my $ticketRequestor = lc($self- | |||
if ($transactionType eq 'Create') { | if ($transactionType eq 'Create') { | ||
return if grep { $ticketRequestor eq lc($_) } @exceptionList; | return if grep { $ticketRequestor eq lc($_) } @exceptionList; | ||
return 1; | return 1; | ||
} | } | ||
return; | return;</source> | ||
'''Code Explanation:''' | '''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 | |||
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 <code>@exceptionList</code> 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 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 | The grep processes the <code>@exceptionList</code> 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 | The "lc" functions in the script makes sure that everything is switched to lower-case to prevent <code>"YOU@there" eq "you@THERE"</code> from returning false. |
Latest revision as of 05:17, 19 February 2018
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.