Bulk closure of hr cases which are created before December 1st 2023 through fix script

Burra Mounika
Tera Contributor

Bulk closure of hr cases which are created before December 1st 2023 through fix script.Need Help?

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Need help with what exactly?

 

You created a script and it is not working? Or your script is failing from a certain part? Please share what steps you already took.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

var gr = new GlideRecord('sn_hr_core_case_benefits');
gr.addEncodedQuery('hr_service=1c3533567d251008bb86ece54bcbfc^sys_created_on<javascript&colon;gs.beginningOfToday()^state=18');
gr.query();
while (gr.next()) {
    gr.state = '3';
    gr.setWorkflow(false);
    gr.autoSysFields(false);
    gr.update();
 
This script is for beginning of today,i need to close the cases before december 31st 2023.How can i update accordingy in the script?please help
 

If it's just about your encodedquery, here is nice method how you can generate your encodedquery from a list, and use it in scripting:

- 2019-09-04 - Article - Utilizing the breadcrumb on lists to generate your query

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn

Just looking at your script, do be aware that the use of setWorkflow(false) can cause other issues. Are you aware of that? And how are you handling that?

 

For example, if there's a Flow or Workflow attached, that will still keep running. If there's a Task SLA attached, that will still keep running. Etcetera.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn