Inbound Email Action to Prevent subject with (RE) replies from creating new ticket

jxa7987
Tera Expert

I am creating an inbound email action for our customized application. The requirement is to Create only New Ticket for emails that sent out to our   4 different mailboxes.

So far tickets are being created but my issue is it also creates new ticket even if the subject has "RE or   FWD". I defined it in my script but since it is not working, all Reply emails are creating new ticket. How can I prevent it? Please help. Thanks.

Below is my inbound email script:

current.description= email.body_text;

current.short_description = email.subject;

current.priority = 3;

current.u_opened_for = gs.getUserID();

var direct = email.direct.toLowerCase();

if (direct.indexOf('Vendors@company')> -1){

current.assignment_group.setDisplayValue('Vendor');

}

if (direct.indexOf('Fico@company')> -1){

current.assignment_group.setDisplayValue('FICO');

}

if (direct.indexOf('Customer@company)> -1){

current.assignment_group.setDisplayValue('Customer');

}

if (email.direct.indexOf('Contracts@company')> -1){

current.assignment_group.setDisplayValue('Contracts');

}

if (email.direct.indexOf('Materials@company')> -1) {

  current.assignment_group.setDisplayValue('Materials');

}

current.insert();

function subjectCheck(subject) {

  var processCheck = true;

  if (subject.indexOf('read:') > -1) {

  processCheck = false;  

  if (debug) {

  logger.logInfo("07. subject: bad");

  }

  }

  if (subject.indexOf('not read:') > -1) {

  processCheck = false;  

  if (debug) {

  logger.logInfo("07. subject: bad");

  }

  }

  if (subject.indexOf('re:') > -1) {

  processCheck = false;  

  if (debug) {

  logger.logInfo("07. subject: bad");

  }

  }

  if (subject.indexOf('fw:') > -1) {

  processCheck = false;  

  if (debug) {

  logger.logInfo("07. subject: bad");

  }

  }

  if (subject.indexOf('RE:') > -1) {

  processCheck = false;  

  if (debug) {

  logger.logInfo("07. subject: bad");

  }

  }

  return processCheck;

}

2 REPLIES 2

Erik Stolberg
Tera Guru

You shouldn't need to build inbound actions using indexOf to check the subject for prefixes... all of that is configured under System Properties > Email Properties. The inbound email fields for reply prefixes and forward prefixes are on the right.



If you look under System Mailboxes > Inbound > Received, do the emails show a Receive Type of New, Reply, or Forward? If they show as Reply, that means the system recognizes it as a reply (using the above mentioned prefix list as well as items listed here in the Wiki).



If the emails are replies, you also need an inbound action to process these. Create a new inbound email action where the type is set to Reply. You should have a baseline "Update Incident (BP)" inbound email action in your system to reference for this.



An easy way to debug why a message isn't processing as expected is to open the inbound message (sys_email table) and scroll to the bottom... The Email Log section will show what inbound email actions were run and why or why not the message was processed using it.


jxa7987
Tera Expert

I overlooked my script and did not declared debug on this part.



function subjectCheck(subject) {


      var processCheck = true;


      var debug = true;




      if (subject.indexOf('read:') > -1) {


              processCheck = false;  


              if (debug) {


                      logger.logInfo("07. subject: bad");


              }


      }