- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 11:45 AM
Hi folks!
I am trying to create a way to close incidents via email, without the need to open ServiceNow.
The main idea is that a user can send an email to the instance or to ServiceNow with the subject "Close incident XXXXX" and that this closes the incident without having to log in to the instance.
Any help is welcome, thank you very much!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 11:51 AM
Hi @Asosa ,
Hope you are doing great.
Email Integration: a. Configure an inbound email action in ServiceNow, which will allow the system to receive and process incoming emails. b. Set up an email account or alias dedicated to receiving incident closure requests via email.
Business Rule: a. Create a business rule that triggers when an email with the subject "Close incident XXXXX" is received. b. Extract the incident number (XXXXX) from the email subject using script logic. c. Use the incident number to locate and close the corresponding incident record.
(function executeRule(current, previous /*, gs*/) {
var emailSubject = current.subject.toLowerCase();
var closeKeyword = "close incident";
if (emailSubject.startsWith(closeKeyword)) {
var incidentNumber = emailSubject.replace(closeKeyword, "").trim();
var incident = new GlideRecord('incident');
if (incident.get('number', incidentNumber)) {
incident.state = 7; // Set the incident state to 'Closed'
incident.update();
}
}
})(current, previous);
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 11:51 AM
Hi @Asosa ,
Hope you are doing great.
Email Integration: a. Configure an inbound email action in ServiceNow, which will allow the system to receive and process incoming emails. b. Set up an email account or alias dedicated to receiving incident closure requests via email.
Business Rule: a. Create a business rule that triggers when an email with the subject "Close incident XXXXX" is received. b. Extract the incident number (XXXXX) from the email subject using script logic. c. Use the incident number to locate and close the corresponding incident record.
(function executeRule(current, previous /*, gs*/) {
var emailSubject = current.subject.toLowerCase();
var closeKeyword = "close incident";
if (emailSubject.startsWith(closeKeyword)) {
var incidentNumber = emailSubject.replace(closeKeyword, "").trim();
var incident = new GlideRecord('incident');
if (incident.get('number', incidentNumber)) {
incident.state = 7; // Set the incident state to 'Closed'
incident.update();
}
}
})(current, previous);
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2024 05:43 AM
Thanks for the post.
I'm just wondering how to configure the inbound action role to close this incident.
Do I have to make to make some adjustments in the role itself for make it work properly?
All advices is appreciated here.