The CreatorCon Call for Content is officially open! Get started here.

Incident not being created by Inbound Email Action "did not create or update incident using current"

Navya43
Tera Contributor

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!

 

 

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Navya43 

are you sure you are giving the mandatory fields during creation?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes, all the mandatory fields are being given. The inc stopped getting created only after I added that block of code

 

 

Anubhav24
Mega Sage

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)

I did, it still doesn't work