- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2025 10:17 AM
Hi Team,
I need to close around 1000 RITMs and around 1800 Catalog Tasks in bulk.
Some RITMs have only one SC Task (Fulfillment, Open, or On Hold) — these should be closed as Cancelled.
Some have multiple SC Tasks with mixed states (Closed Complete, Closed Cancelled, Fulfillment, Preparation, On Hold, etc.) — these should be closed as Complete.
All SC Tasks should be closed first, then the RITMs updated with state, stage, work notes, and inactive status.
I know AI can help with logic, but I trust the ServiceNow Community for standard and expert-level best practices to handle such cases smoothly and efficiently.
Also, since this is a bulk run, please suggest whether it’s better to run the fix script in batches (for example, 100 records per run) or if there’s a safer alternative approach to handle large updates.
Thanks,
Sunayana
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2025 10:14 PM
looks good to me.
Please test it.
also add logic to cancel any pending approval for that RITM and also logic to close REQ
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2025 05:10 AM - edited 11-07-2025 05:17 AM
Your SLAs on request items will continue to run with that
ritmGR.setWorkflow(false);At the end of our clean-up script I used the following so the SLA engine runs to stop the SLAs:
ritmGR.update();
ritmGR.setWorkflow(true);
ritmGR.work_notes = "Closed RITM as clean-up action";
ritmGR.update();From my experience, to avoid future confusion it's best to leave a note in the work notes with why the RITMs were closed. I also stopped using autoSysFields unless I really need it. If you don't want your name plastered on all the RITMs that are closing, an option is to run this script as a scheduled script under System Administrator.
You don't know what happens in the workflow when you close the catalog task. So to make sure nothing gets triggered after you close the catalog task, add this before the sc_task query to already cancel the workflow and approvals:
var currentWorkflow = new Workflow();
currentWorkflow.cancel(ritmGR);And to clean-up the parent request, add this at the end:
var grRequest = ritmGR.request.getRefRecord();
if (grRequest.isValidRecord() && grRequest.active == true) {
grRequest.active = false;
grRequest.state = '3';
grRequest.request_state = 'closed_incomplete';
grRequest.stage = "closed_incomplete";
grRequest.setWorkflow(false);
grRequest.update();
var workflow = new Workflow();
workflow.cancel(grRequest);
}