did not create or update incident using current

Rohith16
Tera Contributor

Hi all i have a requirement in Inbound action where a incident needs to be created from the incoming email which contains as below:

Group: (a group which is present in sys_user_groups table)

Impact: Low

Urgency:Low

So using the inbound action the incident should be created and the Group, Urgency, Impact should be taken from the Email body...... If the Group is not present in the sys_user_group table have to create the Incident with Assignment Group "GroupA"

I have written my code as below but its given an error "did not create or update incident using current"

if (email.body.Group != undefined) {
var emailgroup = email.body.Group;
var emailimpact = email.body.Impact;
var emailurgency = email.body.Urgency;
var rec = new GlideRecord('sys_user_group');
rec.addQuery('name', "=", emailgroup);
rec.query();
if (rec.next()) {
current.short_description = email.subject;
current.description = email.body_text;
current.assignment_group = emailgroup;
current.impact = email.body.Impact;
current.urgency = email.body.Urgency;
current.insert();
}

else{

current.short_description = email.subject;
current.description = email.body_text;
current.assignment_group = "(Sys id of a GroupA)";
current.impact=email.body.Impact;
current.urgency=email.body.Urgency;
current.insert();
}
}

Can anyone help me with the code

1 REPLY 1

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi,

             Can you please try current.insert() only once outside if else block ?