Inbound Action - Trim excess emails & increase user engagement

t_a_rogers
Kilo Expert

This is an 8 year follow up to this LINKED post from ctomasi

There was much discussion on the past but never a clear answer. In short, our company wants to use email exactly as HI representatives do - both with reply-all functionality that maintains all users in the thread when new comments are added, and also to trim excess messages below the main reply message. We trim off the extra emails so that the reply email ONLY adds the content from the sender as an additional comment on the incident - Not the entire mail string below their email.

(While originally typing this I had it as a question, but one of the guys on my team solved it - So now posting as a friendly FYI for others who might find it useful)

This is our inbound email action. The relevant updates are lines 11 & 12, which strip out the junk in the message.

gs.include('validators');

if (current.getTableName() == "incident") {

  var gr = current;

  if (email.subject.toLowerCase().indexOf("please reopen") >= 0)

  gr = new Incident().reopen(gr, email) || gr;

  var removefrom = email.body_text.indexOf('From: ');

  current.comments = email.body_text.substring(0,removefrom);

  if (gs.hasRole("itil")) {

  if (email.body.assign != undefined)

  gr.assigned_to = email.body.assign;

  if (email.body.priority != undefined && isNumeric(email.body.priority))

  gr.priority = email.body.priority;

  }

  gr.update();

}

This is our mail script used on outbound "Incident Commented" emails which applies the technician's name who updated the record as the Display Name in the recipient's outlook.. The goal is to add more personalized engagement than our generic instance's email display name when the user receives messages from us. So far, this mail script seems to work in testing:

})(current, template, email, email_action, event);

var ue = new GlideRecord('sys_user');

  ue.addQuery('user_name', current.sys_updated_by);

  ue.query();

  if(ue.next()){

  email.setFrom(ue.name + ' <' +ue.email+ '>');

  }

Anybody else have good feedback or best practices they want to share?

3 REPLIES 3

Chuck Tomasi
Tera Patron

You shouldn't need to do that in each inbound action Travis. There's an email property (System Properties> Email Properties) that looks for the "delimiter" between the reply and the "junk", as you call it.



find_real_file.png


We have that property set as your image above, but it doesn't strip out messages below the delimiter.



Pre-inbound action:


find_real_file.png



Post-inbound action:


find_real_file.png


Something's not right. That's exactly what that property prevents. The \n\nFrom: is in your string. You may want to reach out to support and ask them why it's not behaving the way it should. You shouldn't have to code the same logic in every inbound action since the platform does it for you.



(My guess is there's another property or something that needs to be configured that I'm missing.)



HI Service Portal - ServiceNow


Contact Support | ServiceNow