Create Incident : did not create or update incident using current

Nilesh Pol
Tera Guru
Hi all, Im trying to create an incident with the verification of a entry of the u_redirect_email in custom table, but I am getting an error message: "Create Incident : did not create or update incident using current"
 
any suggestion will be appreatiated.
 
action type: new, and script:
 
var userQuery = 'active=true^locked_out=false^emailISNOTEMPTY^u_external_idISNOTEMPTY^email=' + email.origemail;
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery(userQuery);
grUser.query();
if (grUser.next()) {
   
        gs.log('User id of the sender met the requirements: ' + email.origemail, 'Inbound Email Action: Create Incident');
    
    var mailQuery = 'u_active=true^u_redirect_addressIN' + email.direct; 
    var mrQuery = new GlideRecord('u_email_to_incident_configuration');
    mrQuery.addEncodedQuery(mailQuery);
    mrQuery.query();
    if (mrQuery.next() && email.subject != '' && email.body_text != '') { /
       
            gs.log('Redirect MailBox is available in the table: ' + email.direct, 'Inbound Email Action: Create Incident');
        
        
        current.cmdb_ci = mrQuery.u_business_service;
        current.assignment_group = mrQuery.u_assignment_group;
        current.u_creator_group = mrQuery.u_creator_group;
        current.priority = mrQuery.u_priority;
        current.service_offering = mrQuery.u_service_offering;
        current.caller_id = grUser.sys_id;
        current.short_description = email.subject;
        current.opened_at = gs.nowDateTime();
        current.u_outage_begin = gs.nowDateTime();
        current.work_notes = "Incident created via Redirected email:-" + "\n\n" + email.body_text;
        current.u_contact = grUser.sys_id;
       
        current.state = 2;
        current.contact_type = "email";
        current.insert();
    }
7 REPLIES 7

Nilesh Pol
Tera Guru

@Ankur Bawiskar  yes its "Processed" state and error in the log is Create Incident : did not create or update incident using current.

 

Did anyone know how email domain managed in the instance. I can see there are emails getting received in email logs from some domain only i.e. @example.com

@Nilesh Pol 

can you add this line and see if that user is able to create?

var userQuery = 'active=true^locked_out=false^emailISNOTEMPTY^u_external_idISNOTEMPTY^email=' + email.origemail;
var grUser = new GlideRecord('sys_user');
grUser.addEncodedQuery(userQuery);
grUser.query();
if (grUser.next()) {

gs.log('User id of the sender met the requirements: ' + email.origemail, 'Inbound Email Action: Create Incident');

var mailQuery = 'u_active=true^u_redirect_addressIN' + email.direct;
var mrQuery = new GlideRecord('u_email_to_incident_configuration');
mrQuery.addEncodedQuery(mailQuery);
mrQuery.query();
if (mrQuery.next() && email.subject != '' && email.body_text != '') { /

gs.log('Redirect MailBox is available in the table: ' + email.direct, 'Inbound Email Action: Create Incident');


current.cmdb_ci = mrQuery.u_business_service;
current.assignment_group = mrQuery.u_assignment_group;
current.u_creator_group = mrQuery.u_creator_group;
current.priority = mrQuery.u_priority;
current.service_offering = mrQuery.u_service_offering;
current.caller_id = grUser.sys_id;
current.short_description = email.subject;
current.opened_at = gs.nowDateTime();
current.u_outage_begin = gs.nowDateTime();
current.work_notes = "Incident created via Redirected email:-" + "\n\n" + email.body_text;
current.u_contact = grUser.sys_id;

current.state = 2;
current.contact_type = "email";

gs.info("user can create" + current.canCreate());
current.insert();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

sunil maddheshi
Tera Guru

@Nilesh Pol Instead of current.insert() Can you try doing a fresh GlideRecord and see if that works

var inc = new GlideRecord('incident');
inc.initialize();
inc.cmdb_ci = mrQuery.u_business_service;
inc.assignment_group = mrQuery.u_assignment_group;
inc.u_creator_group = mrQuery.u_creator_group;
inc.priority = mrQuery.u_priority;
inc.service_offering = mrQuery.u_service_offering;
inc.caller_id = grUser.sys_id;
inc.short_description = email.subject;
inc.opened_at = gs.nowDateTime();
inc.u_outage_begin = gs.nowDateTime();
inc.work_notes = "Incident created via Redirected email:-" + "\n\n" + email.body_text;
inc.u_contact = grUser.sys_id;
inc.state = 2;
inc.contact_type = "email";

var incID = inc.insert();
if (!incID) {
    gs.info("Failed to insert incident record", "Inbound Email Action");
} else {
    gs.info("Incident created with sys_id: " + incID, "Inbound Email Action");
}

Please mark correct/helpful if that helps you, thanks!