How do I close an incident from an inbound email?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 10:03 AM
I am relatively new to SN and have not done much with scripting. I have a new requirement that came in to open an incident from an email with a specific subject line. Then from a later email, find that same incident and close it based on the subject line.
I'm assuming I can configure this via inbound email actions? What scripts should I use to accomplish this goal?
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 10:28 AM
Correct, inbound email actions would be the way to go. You can find out more about configuring inbound email actions here.
Configure the Inbound email action to target the Incident table.
The script you would use to create an incident might look something like this:
current.caller_id = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;
current.category = "inquiry";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";
Closing the incident could be done by sending an email and writing a separate inbound email action to look for those words in the email subject or body along with the incident number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 11:12 AM
Matt thank you this is helpful. Do you have any examples of the scripting language I would use for your last comment? See below:
"Closing the incident could be done by sending an email and writing a separate inbound email action to look for those words in the email subject or body along with the incident number."

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2019 10:29 AM
Hi,
I'm assuming you've already done the open an incident with a specific subject line - inbound action, since you're only asking for closure here. So yes, you'd basically have an inbound action (that the order is set to a lower number than the create incident inbound action) and check the "stop processing" checkbox so that no other inbound action runs after this one.
Then in the condition, you'd set subject contains (blah blah) and ServiceNow automatically looks for the record number in the subject and associates it accordingly. Then in your actions section of the inbound action, you don't even have to code anything really....you can set the state to resolved and all that. Just pick all your fields and set their values.
So the only "kickoff" is really your instance getting the email from the user with the specific subject line, SN looks for the records, and does all the actions you set in that tab. Then the stop processing box stops any others from running.
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
Please mark this as helpful/correct if it answered your question!