- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2020 11:50 PM
hi,
i have an inbound action to create incidents from email.
The requirement is that i want to ignore incident creation if subject is same and add that mail content in existing incident itself.
Please let me know if any idea on this.
ServiceNow Community Rising Star 2022/2023
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2020 12:00 AM
Hi jagjeet,
Assuming subject is stored in short description of incident.
in your inbound action, check like this. This way, if short description exists already for any incident, then it will update the same incident. otherwise, it will create any new incident.
var gr = new GlideRecord("incident");
gr.addQuery("short_description",email.subject.toString());
gr.query();
if(gr.next()) {
gr.work_notes=email.body_text;
gr.update();
}else {
current.short_description = email.subject;
current.description=email.body_text;
//add other fields here.
}
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2020 11:54 PM
Hi Jagjeet,
If you look at the Mailbox > Received - do you see 2 replies? Maybe something is wrong with new email address.
If you look at the email log for the Processed email, do you see 2 inbound actions processing the email?
Hope it will help you!!
If my response helps you then kindly mark my answer helpful 👍and correct ✔otherwise if any query 🤔 feel free to ask further.
Thanks,
Ajim.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2020 12:00 AM
Hi jagjeet,
Assuming subject is stored in short description of incident.
in your inbound action, check like this. This way, if short description exists already for any incident, then it will update the same incident. otherwise, it will create any new incident.
var gr = new GlideRecord("incident");
gr.addQuery("short_description",email.subject.toString());
gr.query();
if(gr.next()) {
gr.work_notes=email.body_text;
gr.update();
}else {
current.short_description = email.subject;
current.description=email.body_text;
//add other fields here.
}
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2020 12:09 AM
That looks promising. Should i use this as script include or i can embed the code in script section itself in inbound action form.
ServiceNow Community Rising Star 2022/2023

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2020 12:23 AM
Hi,
you can embed this directly in the script section of inbound action.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP