Need a fix script to close some corrupt HR cases

Christina23
Tera Contributor

Hello, I have a list of about 10 HR cases that are corrupt (give record not found error when trying to open). We think this was due to a poorly created inbound action which has since been addressed. However, now I would like to close the cases using a background script. So far, I have the below script, but it isn't working so I think it needs some tweaking. Thank you in advance!

Christina

 

var gr = new GlideRecord('sn_hr_core_case_workforce_admin');
gr.addQuery('number','HRC2477494','HRC2475136');    
gr.query();
if(gr.next())
{
 
   gr.state= 3; //to close;
   gr.update();
}
7 REPLIES 7

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Christina23 

 

10 is very less counts and you can do manually via list view in 1 go.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Kilo, 

 

As the records are corrupt, I'm not able to make any updates to them in listview, I have tried multiple ways 🙂

 

Thank you,

 

Christina

Ankur Bawiskar
Tera Patron
Tera Patron

@Christina23 

did you check any mandatory fields needs to be set while closing HR case?

any data policy is blocking?

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