New HR Case Creation from the Email sent to already Closed HR Case

Tahzeeb
Giga Expert

Hello Experts,

 

I have a requirement where in User is Sending Email for the already closed HR Case.

Right now we have a Function where the reply is getting recorded as Comment in the Case.

I need to implement the solution where in a new HR Case is getting created in the above scenario and also no Comment is added to already Existing HR Case.

Kindly provide some guidelines on how to do it.

 

Regards,

TM

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,

There is a good article from ServiceNow itself on the same topic on how to handle this. Please see the comments below:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0794209

Use the following logic to add an inbound email action on a Business Rule:

// Where 6 is the value of your resolved state
if (current.state == 6) {
//Your inbound code here
}

if (current.active == false) {
// Activate a ticket is closed event if active is false (closed)
gs.eventQueue("ticket.closed", current, current.state, previous.state);
}

If the CASE/Incident is closed you can fire an event, which sends an email.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

7 REPLIES 7

Markus Nilsson
Tera Guru
Tera Guru

Hi,

Another way is would be to create a notification that bounce when someone trying to update a closed case, in that notification you can direct them to the portal and stating they are trying to update a closed case, please submit another one.

 

/Markus

Best regards,
Markus Nilsson
+46709389974

shloke04
Kilo Patron

Hi,

There is a good article from ServiceNow itself on the same topic on how to handle this. Please see the comments below:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0794209

Use the following logic to add an inbound email action on a Business Rule:

// Where 6 is the value of your resolved state
if (current.state == 6) {
//Your inbound code here
}

if (current.active == false) {
// Activate a ticket is closed event if active is false (closed)
gs.eventQueue("ticket.closed", current, current.state, previous.state);
}

If the CASE/Incident is closed you can fire an event, which sends an email.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Tahzeeb
Giga Expert

Thank you for the reply..Requirement is to create a new case

 

I am using below Code

 

var checkState = new GlideRecord('sn_hr_core_case');

checkState.addQuery('number',current.number);

checkState.addQuery('state','closed');

checkState.query();

if(checkState.next())

{

var newCase = new GlideRecord('sn_hr_core_case');

newCase.initialize();

newCase.field_values = checkState.field_values;

newCase.insert();

 

This is not working.

Regards,

TM

Hi,

Where are you writing this piece of code?

 

I would suggest you can update the existing Inbound action and within this we can create a new HR Case when some one tries to update a Closed Case as shown below:

Navigate to the below URL:

https://instance.service-now.com/nav_to.do?uri=sysevent_in_email_action.do?sys_id=7a5370019f22120047a2d126c42e7063

Replace "instance' with your instance name.

Use the script as below:

gs.include('validators');

if (current.getTableName() == "sn_hr_core_case") {
    current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

    if (current.getTableName() == 'sn_hr_core_case' && current.state == 3) {
        createNewHRCase(current);
    }

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

    current.update();


}

function createNewHRCase(current) {
    var gr = new GlideRecord('sn_hr_core_case');
    gr.initialize();
    gr.FIELD_NAME = current.FIELD_Name;
    gr.insert();
}

 

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke