stop duplicate emails from inbound action

JagjeetSingh
Kilo Sage
Kilo Sage

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.

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023
1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

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

View solution in original post

12 REPLIES 12

Azim Kazi
Giga Guru

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.

asifnoor
Kilo Patron

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

That looks promising. Should i use this as script include or i can embed the code in script section itself in inbound action form.

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

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