email processing

joedumond
Tera Contributor

What's the proper protocol for handling email replies to the instance?

When an incident is created, an email is sent.

When an incident is commented or worknoted, an email is sent.

I am seeing issues when someone replies to the incident notification.

It appears to happen when the Replier adds people to the To: or CC: line of the reply.

I can't quite narrow it down, and can't find the default email handling protocol for incident replies.

My best practice tells me that the Replier should leave the email alone and the body of the message becomes the comments.

If they want to add people that should be done through the watchlist of the incident.

1 ACCEPTED SOLUTION

Ahh - OK, I see. Forgive me if I start too far back this time.



Out of the box, ServiceNow uses the Inbound Actions to process email that comes into the instance. Email actions can be created for different message types - New, Reply or Forward. When an email message is received by ServiceNow, it checks for the watermark (the REF:xxxxxxx number at the bottom), and if the watermark exists, it knows what table the message is in relation to. It then checks for an Inbound Actions that matches the message type (New, Reply, Forward) and the table.



I think that gives enough basic background, if not let me know.



Your question is about replies to an Incident. If you open up your Inbound Actions you will see several items that relate to the "Incident" table. Out of the box, you will see one that handles replies ("Update Incident (BP)"). This Inbound Action determines what to do when an email reply is sent that relates to an Incident.



The code is this:


gs.include('validators');




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


  current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;



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


  current.state = "2";


  current.work_notes = "The caller did not feel that this issue was resolved";


  }



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


  if (email.body.assign != undefined)


  current.assigned_to = email.body.assign;



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


  current.priority = email.body.priority;


  }



  current.update();


}



Basically, what this does it append the incoming email to the "Comments" field of the Incident record that is referenced in the watermark. It also looks for a subject that contains "please reopen", and if found in the subject, reopens the Incident. There are some other actions there too, but I would recommend commenting them out (and I would comment out the "reopen" one) unless you really want to use them.



I think that covered what the system does, out of the box, when an inbound email arrives in reply to an existing Incident.



You can troubleshoot the emails you receive by going into the Email Log, opening up the email in question, and you will see which Inbound Action it triggered. This should help with your debugging if you find that something is happening you are not wanting/expecting. And, with the explanation above, hopefully it is easy to see how the Inbound Actions work so that you can edit them as needed.



I hope I didn't jump too far ahead again on you, and that this will help you troubleshoot what is happening with your inbound emails. If not, just let me know where I can expand!


View solution in original post

12 REPLIES 12

There is a system property that may be of use - it is under the "Inbound Mail Configuration" titled "Discard everything below this test...".



It would be relatively simple to just create a function and discard the rest of the body based on the characters, provided your organization uses a standard email client (as the formatting will be expected). You should be able to program other clients as well (based on their formatting). Really, the email is one giant string so it should be easy to detect at what position the formatting starts and erase beneath it. The catch is developing the logic for each of your clients (including smart phones).



You would then leave the message itself intact (the "Outlook style message" as we refer to it) and your additional comment would be the filtered copy. Just in case you filtered something you shouldn't (or someone replies within the original body).


Ishan5
Kilo Explorer

Hi,

In my dev instance i am trying to populate a field called as "Feedback" from inbound email action. My mail body has txt as 

Feedback:GOOD

In my script i am able to get value if i do email.body_html (this give me whole html). However when i try to do email.body_html.feedback, nothing happens. 

 

Perhaps there is a feature I am unaware of, but I have never seen the ability for you to dotwalk through the email message itself to pull out text. I have always had to parse it out myself.

 

Here is the doc on the email object - I see no mention of what you are trying to do:

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/notification/reference/r_AccessingEmailObjsWithVars.html

 

Instead I would think you have to look for the string "Feedback:" and copy whatever is after it (up to whatever character / space / link break will end the string).

 

Again I could be completely wrong and have been doing it the hard way all along. I have just never heard of being able to call out pieces of the email like that.