Reopen Case

CLM
Tera Contributor

Hello Community,

 

Is there a way to reopen a case once it has been cancelled?

1 ACCEPTED SOLUTION

Sumanth16
Kilo Patron

Hi @CLM ,

 

It is not best practice to reopen Cancelled case. Ask user to create another new case.

 

But if you want to do it ,try to reopen using background script:

 

var gr= new GlideRecord('sc_request')//change to case table

 

gr.addQuery('sys_id', 'sample sys_id');//change to case sysid

 

gr.query();

 

while(gr.next()) {

 

        gr.request_state="open";//update to your state number

 

  new WorkflowApprovalUtils().cancelAll(gr, "comment");

 

var wf1 = new global.Workflow();

 

wf1.restartWorkflow(gr,true);

 

        gr.update();



}

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Thanks & Regards,

Sumanth Meda

 

View solution in original post

10 REPLIES 10

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

An HR case? A CSM case? A Now Support Case? Something else?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

CLM
Tera Contributor

My apologies. This is in regards to an HR case.

Hi @CLM,

 

Thanks for clarifying.

It’s late this end so I can provide an updated script for HR cases tomorrow morning for you, but in theory you would need to do is update the table name in the GlideRecord lookup and also update the state value (if required) to the required HR state value.

 

However, as HR is a scoped app and due to the security measures, this is not going to be as easy as just as the theory.

I'll take a look and get back to you.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

 

Hi @CLM,

 

As I mentioned, due to the security constraints around HR (which should not be ignored) , I've updated the below script. This script should be copied into a Fix Script making sure your in the correct Scope: Human Resources: Core.

 

@CLM- Please make sure you have spoken with the HR dev/admin before running this to make sure all use cases have been thought about, related cases, SLA's reports, metrics. etc etc.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

 

Screenshot 2024-08-08 at 10.12.59.png

 

var reopenCaseGR = new GlideRecord('sn_hr_core_case') 
reopenCaseGR.addQuery('sys_id', '477e03320b30220097432da0d5673a83'); //change to sys_id of the case you wish to update
reopenCaseGR.query();
if (reopenCaseGR.next()) {
    reopenCaseGR.state = 18; //state value for Work Inprogress in HR. Feel free to update to state value you require to move to eg 10 for Open
	reopenCaseGR.work_notes = 'Reopen comment. Add text here which will be visible in the Case notes';
    reopenCaseGR.update();
}

Robbie
Kilo Patron
Kilo Patron

Hi @CLM,

 

(Re posting so my latest response is not lost in the thread)

As I mentioned, due to the security constraints around HR (which should not be ignored) , I've updated the below script. This script should be copied into a Fix Script making sure your in the correct Scope: Human Resources: Core.

 

@CLM- Please make sure you have spoken with the HR dev/admin before running this to make sure all use cases have been thought about, related cases, SLA's reports, metrics. etc etc.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

 

Robbie_0-1723133857534.png

 

var reopenCaseGR = new GlideRecord('sn_hr_core_case') 
reopenCaseGR.addQuery('sys_id', '477e03320b30220097432da0d5673a83'); //change to sys_id of the case you wish to update
reopenCaseGR.query();
if (reopenCaseGR.next()) {
    reopenCaseGR.state = 18; //state value for Work In progress in HR. Feel free to update to state value you require to move to eg 10 for Open
	reopenCaseGR.work_notes = 'Reopen comment. Add text here which will be visible in the Case notes';
    reopenCaseGR.update();
}