Create new INCIDENT if email is sent to Closed ticket

Raj12341
Tera Contributor

 REQ - We have seen an uptick in frustrated users not getting a response because they are responding to emails to tickets that are in a closed state. Seems like there is no NDR or auto-reply to say that the incident has not been updated because the ticket is closed.

Please can we either have a new Incident created if an email is sent to a Closed ticket.

I have written code but it is not working fine.

 

current.short_description = email.subject;

var sid = gs.createUser(email.from);

current.caller_id = sid;
current.opened_by = sid;
current.category = "request";
current.incident_state = 1;
current.notify = 2;
current.contact_type = "email";

 if (current.state == 6 || current.state == 7) {
        current.comments = 'User replied to a Closed incident. Ticket will be reopened.';
        current.state = 2;
        current.update();
    }

if (email.body.assign != undefined)
   current.assigned_to = email.body.assign;

if(email.importance != undefined)
   if (email.importance == "High")
      current.priority = 1;

if (email.body.priority != undefined)
   current.priority = email.body.priority;

current.insert();
2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

Hello @Raj12341,
For similar kind of requirement, please refer to the link below:
https://www.servicenow.com/community/itsm-forum/email-inbound-action-incident-closed/m-p/784395

 

Mark my correct and helpful, if it is helpful and please hit the thumbs-up button to mark it as the correct solution.
Thanks & Regards,
Abbas Shaik

 

 

Tai Vu
Kilo Patron
Kilo Patron

Hi @Raj12341 

You can try the below script to create a new incident when an Inbound Reply to a Closed Incident.

 

if (current.active == false) {
    var grINC = new GlideRecord('incident');
    grINC.initialize();
    grINC.caller_id = gs.getUserID() || current.caller_id; //current user or caller from closed inc
    grINC.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
    grINC.short_description = email.subject;
    grINC.category = "request";
    grINC.incident_state = IncidentState.NEW;
    grINC.notify = 2;
    grINC.contact_type = "email";

    grINC.assigned_to = (email.body.assign != undefined) ? email.body.assign : current.assigned_to;

    if (email.importance != undefined) {
        if (email.importance.toLowerCase() == "high") {
            grINC.impact = 1;
            grINC.urgency = 1;
        }
    } else {
        grINC.impact = current.impact;
        grINC.urgency = current.urgency;
    }

    var notes = "A new Incident created due to an email is sent to a Closed ticket: [code]<a href='incident.do?sys_id=" + current.sys_id + "' > " + current.number + "</a>[/code]";

    grINC.work_notes = notes;
    grINC.insert();
}

 

 

Cheers,

Tai Vu