Script to mass close cases
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2024 06:35 AM
We are trying to mass close all cases of a certain HR Service type. We'd like to move any case for this HR Service that is still active to a Closed Complete state. Would a scheduled job be the best way to do this? Or is there another way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2024 06:52 AM
Use flow designer, low code/ no code.
Trigger
Schedule
Action
Look up records
Update record
and work done.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2024 08:50 AM
Thank you! This is what I have so far- am I on the right track?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2024 07:59 AM
@Rylie Markle You can write a fix script to close such cases in bulk. Here is an example script which you can use.
Here is the script.
var glideHRCase = new GlideRecord('sn_hr_core_case');
glideHRCase.addEncodedQuery('hr_service=6628cde49f331200d9011977677fcf0b^active=true');
glideHRCase.query();
while (glideHRCase.next()) {
glideHRCase.setValue('state', '3'); //3 Closed complete
glideHRCase.setWorkflow(false);
glideHRCase.update();
}
In this script replace 6628cde49f331200d9011977677fcf0b with the sys_id of your HR Service.
Hope this helps.