Incident not being created by Inbound Email Action "did not create or update incident using current"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:05 PM
Hi,
The Inc was successfully being created unless I added these this piece of code which gave the error as "did not create or update incident using current"
The block of Code I added:
var subject = email.subject.trim();
if(subject.indexOf("HHC Upload") != "-1"){
current.caller_id = gs.getUserID();
current.category = "handheld";
}
else{
current.caller_id = gs.getUserID();
current.category = "inquiry";
}
The entire code:
var email_Body;
var grp_name;
var isDuplicate = new CTS_Cyg_Integration_Utils();
var duplicate_Res = isDuplicate.MSMQ_Biz_duplicateHandler(email.subject.trim());
//Remove Disclaimer
var emailBodytrimmed = removeDisclaimer();
if(duplicate_Res == "false"){
current.short_description = email.subject.trim();
current.description = emailBodytrimmed;
var subject = email.subject.trim();
if(subject.indexOf("HHC Upload") != "-1"){
current.caller_id = gs.getUserID();
current.category = "handheld";
}
else{
current.caller_id = gs.getUserID();
current.category = "inquiry";
}
email_Body = email.body_text.toString();
grp_name = parseGroupname(email_Body, "GROUP=" , "%SUMMARY");
current.setDisplayValue('assignment_group', grp_name);
current.contact_type = "email";
if(subject.indexOf("Critical") != "-1"){
current.impact = 1;
current.urgency = 2;
}
else if(subject.indexOf("Alert") != "-1"){
current.impact = 2;
current.urgency = 2;
}
else{
current.impact = 2;
current.urgency = 2;
}
current.incident_state = IncidentState.NEW;
current.comments = "received from: " + email.origemail + "\n\n" + emailBodytrimmed;
current.insert();
}
else if (duplicate_Res != "error"){
var update_Ex_Inc = new GlideRecord('incident');
update_Ex_Inc.get(duplicate_Res.trim());
update_Ex_Inc.query();
if (update_Ex_Inc.next()) {
update_Ex_Inc.u_incident_occurence_count = update_Ex_Inc.u_incident_occurence_count + 1;
update_Ex_Inc.work_notes = gs.getMessage('MSMQ_Inc_Occ') + ':' + update_Ex_Inc.u_incident_occurence_count + "\n\n\n" + "received from: " + email.origemail + "\n\n" + emailBodytrimmed;
update_Ex_Inc.update();
}
}
Thanks for your help in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:12 PM
are you sure you are giving the mandatory fields during creation?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 12:27 AM
Yes, all the mandatory fields are being given. The inc stopped getting created only after I added that block of code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 12:51 AM
Hi @Navya43 ,
if(subject.indexOf("HHC Upload") != "-1")
Can you remove the quotes from != condition and see if it works , if(subject.indexOf("HHC Upload") != -1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 01:26 AM
I did, it still doesn't work