Removing agent from Cc header when using Service Management

since: 3.3.105

Any Headers you wish to alter must be in the Matching Headers csv, or they will not be processed!

When receiving an email it may contain an agent email address in the Cc header which may add the agent as request participants. This solution will filter the email addresses from the Cc header and will remove any email addresses that are associated to a agent and will add any non agent Jira users as the request participant and any non Jira users as email participants.

This solution uses custom fields to store the email addresses. The custom fields used are:

  • Email Participants - Stores participants that are not users.

  • Sender Name - Store senders name.

  • Sender Address - Stores senders email Address.

  • Request Participants - Stores participants that are users.

Example Email

MIME-Version: 1.0 Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT) Date: Sun, 19 Jun 2011 17:42:26 +1200 Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com> Subject: Filtering out agents from CC header From: reporter@localhost.com To: mailbox@localhost Cc: "noAccount" <noAccount@localhost>, "agent" <agent@localhost.com>, "noAccount2" <noAccount2@localhost>, "Customer" <customer@localhost.com> Content-Type: text/plain; charset=UTF-8 Filtering out agents from CC header.

Example Script

print('ccAddresses : '+ccAddresses.length); var csvVal=""; for (i =0; i<ccAddresses.length; i++) { /*Checks if the email is a user*/ var ccInetAddr = ccAddresses[i];   var theUser = jemhUtils.getUserByEmail(ccInetAddr);     /*Checks if theUser is null*/   if (theUser!==null)   {   /*Checks if theUser email is a user in service desk group*/   var isAgent = groupManager.isUserInGroup(theUser, "jira-servicedesk-users");   if (!isAgent)   { /*If theUser is not in group it will add the email to csvVal*/   if (csvVal=="")   {   csvVal=ccInetAddr.getAddress();   }   else   {   csvVal=csvVal+", "+ccInetAddr.getAddress();   }   }   else   {   /*Prints out the agents name and email address*/     print('Agent is in email Cc:['+i+'] = [email='+ccInetAddr.getAddress()+', user='+theUser.getName()+', isAgent='+ isAgent + "]" );   }   }   else   {   /*Adds the non jira user to csvVal*/ if (csvVal=="")   {   csvVal=ccInetAddr.getAddress();   }   else   {   csvVal=csvVal+", "+ccInetAddr.getAddress();    }   } } /*Updates the Cc header to the new filtered value of csvVal*/ print('New Filtered Cc: ' + csvVal); headerBeans.get('cc').setUpdatedVal(csvVal);

Agent Group

The Agent that this example is trying to filter out is “Agent” and this user is placed in the “jira-servicedesk-users” and the script will check if the email is linked to a user in that script. Below is the Agent’s user profile and shows that they are in the group.

Pre-Proc Script Preview

Preview HeaderScripts Console Output

When creating a Pre-processing script there is a Preview HeaderScripts section and this shows the Output of the script by running the script against a test case. The output will show the Agents that were in the Cc header and shows the new Cc header output with the Agents removed.

Report Output

The Report will have a Pre-Processing section that will show the information that the Pre-Processing task modified and what it modified.

 

Issue Preview

Custom Field values:

  1. This is the Email Participants Custom Field. This stores the email addresses that are not a Jira user and these addresses are saved in the Email Participant Custom Field.

  2. This is the Request Participants Custom Field. These addresses are users that have an account on Jira but they are not agents but are participants to this issue.