Do not email user if they are requestor when also admin cc of a queue

Hello,

I have an administrator here in my department that is a Queue Admin CC but he also puts in a lot of tickets for special requests from our contractors. He is then the Queue Admin CC and the Requestor. Also, the contractors have a group email address that is also the admin cc. Therefore, he ends up getting multiple emails for one ticket. I have tried the coding from the “Notifications Tuning” that is supposed to limit the emails sent out if they are the same for multiple fields; however, that did not work as expected. I fixing the queue and making a new group that includes the individual set of contractors so that he doesn’t get emails that way, but that’s not what he wants.

My question is in two parts (Code will be included at the ends):

  1.  How can perform a custom condition in the scrips for the queue to not send an email to admin Cc if his email address matches the requestor?
    

OR

  1.  If I reverse my settings and take him off of admin CC and put him back in the group, how can I check for his email address and code it only to send one email address ?
    

Here’s the coding for question number one:

Description: Notify AdminCc only if not Requestor
Condition: User Defined
Action: Notify AdminCcs
Template: Custom

Custom Condition:

First set of code I tried by using another example:

my $trans = $self->TransactionObj;

return 1 unless $Ticket->RequestorAddresses eq $Ticket->QueueObj->AdminCcAddresses;
Return 1;

Second code:

my $trans = $self->TransactionObj;
my $admincc = $self->QueueObj->AdminCcAddresses;
my $requestor = $self->RequestorAddresses;

return 0 unless $requestor == RT::Nobody->id;
return 1;

If somone could help me get the coding down that would be great. I don’t fully understand Perl yet.

V/R,

Daniel Moore
IT Systems Technician
Osborne Wood Products, Inc.
[http://hosting-source.bm23.com/9241/public/OsborneLogo111.jpg]
P: 706.282.5764
F: 888.777.4304
http://www.osbornewood.com

The simplest solution is that the administrator manually removes themselves
as a requestor when putting in their own tickets. The simplest coding for
this solution (unless your administrator is willing to do this manually on
every ticket creation) is to write a scrip on this queue that runs on
ticket creation time and manually removes the administrator’s address if it
appears in the list of requestors.

Let me know if that’s not an acceptable solution, and we can work further
on the scrips that filter the emails.On Sun, 1 Mar 2015 at 00:17 Daniel Moore Daniel.Moore@osbornewood.com wrote:

Hello,

I have an administrator here in my department that is a Queue Admin CC but
he also puts in a lot of tickets for special requests from our contractors.
He is then the Queue Admin CC and the Requestor. Also, the contractors have
a group email address that is also the admin cc. Therefore, he ends up
getting multiple emails for one ticket. I have tried the coding from the
“Notifications Tuning” that is supposed to limit the emails sent out if
they are the same for multiple fields; however, that did not work as
expected. I fixing the queue and making a new group that includes the
individual set of contractors so that he doesn’t get emails that way, but
that’s not what he wants.

My question is in two parts (Code will be included at the ends):

  1.  How can perform a custom condition in the scrips for the queue to
    

not send an email to admin Cc if his email address matches the requestor?

OR

  1.  If I reverse my settings and take him off of admin CC and put him
    

back in the group, how can I check for his email address and code it only
to send one email address ?

Here’s the coding for question number one:

Description: Notify AdminCc only if not Requestor

Condition: User Defined

Action: Notify AdminCcs

Template: Custom

Custom Condition:

First set of code I tried by using another example:

my $trans = $self->TransactionObj;

return 1 unless $Ticket->RequestorAddresses eq
$Ticket->QueueObj->AdminCcAddresses;

Return 1;

Second code:

my $trans = $self->TransactionObj;

my $admincc = $self->QueueObj->AdminCcAddresses;

my $requestor = $self->RequestorAddresses;

return 0 unless $requestor == RT::Nobody->id;

return 1;

If somone could help me get the coding down that would be great. I don’t
fully understand Perl yet.

V/R,

Daniel Moore

IT Systems Technician

Osborne Wood Products, Inc.

[image: http://hosting-source.bm23.com/9241/public/OsborneLogo111.jpg]

P: 706.282.5764

F: 888.777.4304

http://www.osbornewood.com

On further thought, I realise that a custom condition on the “send email to
Admin CCs” scrip is not a solution—you can only use such a condition to
send either all admin CC emails or none (i.e. you can’t send to some admin
CCs and not others this way).

To achieve your desired behaviour without adjusting the ticket’s watchers
(i.e. requestor list), you would need to monkey-patch the underlying code
of your RT installation responsible for sending emails. It has been done
before, and someone has kindly written up something on the wiki about it:

It’s not ideal though, because it complicates RT upgrades/migrations and it
also makes RT behave in a manner contrary to its documentation.

I still think that removing your administrator’s email address from the
Requestor field of each ticket is the best solution. By doing this with a
scrip, your administrator wouldn’t even need to know that it’s happening.
Additionally, if you do any reporting on tickets that requires the
Requestor fields to be complete, you could always write a scrip to re-add
them as a requestor when the ticket is resolved.

What are your thoughts at this time?On Mon, 2 Mar 2015 at 22:46 Daniel Moore Daniel.Moore@osbornewood.com wrote:

Hi Alex,

Thank you for the information. The administrator cannot remove themselves
as a requestor. My code in my example is horribly wrong; however, I believe
it is pretty close to what I need. I am new to Perl. If someone could
possibly help me clean up the code where, on submission of the ticket
transaction (correspond) it checks the requestor email and admin cc email
against each other and if they are the same then it only sends to the
requestor. I am putting the code in the script that sends to Admin CCs
(both queue admin cc and ticket admin cc). I cannot figure out the IF
statement and validation checks. That seems to be the only acceptable
solution to me.

V/R,

Daniel Moore

IT Systems Technician

Osborne Wood Products, Inc.

[image: http://hosting-source.bm23.com/9241/public/OsborneLogo111.jpg]

P: 706.282.5764

F: 888.777.4304

http://www.osbornewood.com

From: Alex Peters [mailto:alex@peters.net]
Sent: Saturday, February 28, 2015 5:12 PM
To: Daniel Moore; rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Do not email user if they are requestor when
also admin cc of a queue

The simplest solution is that the administrator manually removes
themselves as a requestor when putting in their own tickets. The simplest
coding for this solution (unless your administrator is willing to do this
manually on every ticket creation) is to write a scrip on this queue that
runs on ticket creation time and manually removes the administrator’s
address if it appears in the list of requestors.

Let me know if that’s not an acceptable solution, and we can work further
on the scrips that filter the emails.

On Sun, 1 Mar 2015 at 00:17 Daniel Moore Daniel.Moore@osbornewood.com wrote:

Hello,

I have an administrator here in my department that is a Queue Admin CC but
he also puts in a lot of tickets for special requests from our contractors.
He is then the Queue Admin CC and the Requestor. Also, the contractors have
a group email address that is also the admin cc. Therefore, he ends up
getting multiple emails for one ticket. I have tried the coding from the
“Notifications Tuning” that is supposed to limit the emails sent out if
they are the same for multiple fields; however, that did not work as
expected. I fixing the queue and making a new group that includes the
individual set of contractors so that he doesn’t get emails that way, but
that’s not what he wants.

My question is in two parts (Code will be included at the ends):

  1.  How can perform a custom condition in the scrips for the queue to
    

not send an email to admin Cc if his email address matches the requestor?

OR

  1.  If I reverse my settings and take him off of admin CC and put him
    

back in the group, how can I check for his email address and code it only
to send one email address ?

Here’s the coding for question number one:

Description: Notify AdminCc only if not Requestor

Condition: User Defined

Action: Notify AdminCcs

Template: Custom

Custom Condition:

First set of code I tried by using another example:

my $trans = $self->TransactionObj;

return 1 unless $Ticket->RequestorAddresses eq
$Ticket->QueueObj->AdminCcAddresses;

Return 1;

Second code:

my $trans = $self->TransactionObj;

my $admincc = $self->QueueObj->AdminCcAddresses;

my $requestor = $self->RequestorAddresses;

return 0 unless $requestor == RT::Nobody->id;

return 1;

If somone could help me get the coding down that would be great. I don’t
fully understand Perl yet.

V/R,

Daniel Moore

IT Systems Technician

Osborne Wood Products, Inc.

[image: http://hosting-source.bm23.com/9241/public/OsborneLogo111.jpg]

P: 706.282.5764

F: 888.777.4304

http://www.osbornewood.com