How to link an email to the appropriate incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 06:13 AM
If the incident is not resolved or not closed, I need to
- link the inbound email to the appropriate incident,
- Add the reply email (only) to the work-notes within.
Any help would be appreciated.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 08:32 AM
Hi Soni,
There is a very detailed WIKI article that shows how inbound emails are processed:
http://wiki.servicenow.com/?title=Inbound_Email_Actions
Section 3.4 discusses matching an email to a specific record.
3.4 Matching Incoming Email to Existing Records
By default, ServiceNow searches email for a watermark to match the incoming email to an existing record in the system. ServiceNow searches for watermarks in the following locations, in this order:
- The email subject line.
- The email body.
- The In-Reply-To header, to see if it contains a message ID. If the email contains this header, the instance uses the ID to look up the watermark.
If there is still no match, the instance tries to match the email with an existing record. The instance determines if the subject line starts with a recognized reply prefix (as defined by the glide.email.reply_subject_prefix property). If the subject line starts with a recognized reply prefix, the instance searches for a record number with a recognized numbering prefix, such as INC for incidents or CHG for changes. If such a number is present in the subject line and a record with that number exists in the appropriate table, the instance associates the email with the matching record number. Otherwise, ServiceNow uses the inbound email action for new emails (by default, new email creates an incident).
The second part of your request is not totally clear to me. Do you want to update the incident work notes with the entire reply email body, or only the new part of the email being received. Since this is a "reply" email, there may be some special character at the start of the pre-existing lines, like >.
Another way to show the existing email, would be the use of From: Sent: To: Subject: block from the original email.
The email.body_text field contains all of the email body. You can parse through this variable and only store the data that meets your requirement. You would need to figure out how to distinguish which parts you want to keep, and which you would like to remove.
There is an out-of-the-box inbound email action that is designed to update an incident from an email:
/nav_to.do?uri=sysevent_in_email_action.do?sys_id=3f789469c0a80064015ad36dc4205a9a
This inbound action does not use any Condition checks, but this is where you would want to look for not resolved or not closed.
You may want to start with this as a model, and add the logic to check to see if the incident is not resolved or not closed, and if these conditions are met, then the inbound action should be processed. Line 4 shows an update to "comments" but based on your request, you would want to update the work_notes field.
My suggestion would be to start with the default inbound email action called "Update Incident" and get this to work. Then, change the name, and "Insert and Stay" to create a new inbound action. Mark the original as not active (so you will always have a clean backup). Slowly start making changes to the new inbound action to add the condition to check to make sure the incident is not closed or resolved. Then, change from the comments to the work_notes. By this time, you should have a good understanding of how this all works, and you can then get to the part of parsing the inbound email body to extract the parts that you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:09 AM
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:12 AM
Hi Soni,
What would be the expected incoming email content?. Would it be reply to an email generated from ServiceNow? That case it would be very easy to achieve.
Thanks
Srini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2016 10:19 AM
I think so . can you explain a bit more that how it can be achieved pls.