How to create a new case when anyone replying to the closed case

wefw
Tera Contributor

Hi There,

If anybody replying to a closed case then it should create new case. for now whatever we are replying to closed case it just updating the existing case, but we don't want to update instead it should create new case from that reply email.

Thanks

4 REPLIES 4

Filipe Cruz
Kilo Sage
Kilo Sage

Hello wefw,

In your inbound action, perform an initial validation on the script to check if the current.state is closed.
If so, initialize a new GlideRecord and insert it, generating a new case.

Hope this helps!

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Best Regards,

Filipe Cruz




Sourabh26
Giga Guru

Hi,

 

You should not update any closed tickets (either it is case/request/incident etc.) as this is not recommended from Service Now and not the best practice as well.

 

Once the ticket is closed then all the fields should be grey out so that no user is able to update anything on this.

 

Mark this as Helpful/Correct, if Applicable.

 

Regards,

Sourabh

Ravi9
ServiceNow Employee
ServiceNow Employee

you can definitely try what filipe said for sure but there are some catch 

1. typically reply emails will have watermark which means by default the email will get associated with the closed case so you will need to override this and stop updating the closed case 

2. i dont know if its a valid use case for u but in some cases users might respond to an old case using number in subject and constructing a new one , especially hr end users , in those cases you will need some handling too via complex validation 

Navneeta
Tera Contributor

Hi,

You need to write inbound email action.

 

// when user replies to the closed email notification a new ticket should get create instead of re-opening the existing ticket

//here is the code

 if (current.getTableName() == "incident") {

        var reply = "reply from: " + email.origemail + "\n\n" + email.body_text;

        if (current.active == true) {

            // Update existing Incident

            current.comments = reply;

            //gs.eventQueue("incident.commented", current, gs.getUserID(), gs.getUserName())

            current.state = '-50';

            current.update();

        } else {

            // Create a new Incident

            var inc = new GlideRecord('incident');

            inc.initialize();

            inc.short_descripion = current.short_description;
            inc.description = reply;
            inc.priority = current.priority;
            inc.caller_id = current.caller_id;
            inc.category = current.category;
            inc.subcategory = current.subcategory;
            inc.cmdb_ci = current.cmdb_ci;
            inc.assignment_group = current.assignment_group;
            inc.work_notes = current.work_notes;

           // other fields

            inc.insert();


            current.work_notes = 'Opened new Incident from email: ' + inc.number;

            current.update();

        }

    }

}(current, event, email, logger, classifier);