We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to bulk set RITMs inactive (active=false) for particular Assignment Group

storiesbyjo
Tera Contributor

Hi All,
I need to make RITMs inactive (active = false) where the assignment group is "Test Group"`. There are approximately 30,000+ matching records.

Questions:

  1. What is the best practice to perform this bulk update safely in Production?
  2. Should I use Scripts – Background?
  3. Any rollback considerations or audit tips you suggest?
4 REPLIES 4

jonsan09
Giga Sage

I would use a background script. Testing in a subProd instance first. I'd suggest utilizing ".setLimit()" to run in batches to catch any issues and prevent instance performance degradation. You might also want to log the RITM number before setting to inactive.

 

A few other things to consider:

  • Does the RITM have any open or active tasks or approvals?
  • Do you need to avoid modifying timestamps and running engines (i.e notifications, business rules, flows)
    • You may need to utilize "setWorkflow()" and/or "autoSysFields()"
  • Depending on your use case and if other related records need to be closed (catalog tasks, approvals), you might be better off cancelling at REQ level. (Might now work if used with "setWorkflow()" )

Chaitanya ILCR
Giga Patron

Hi @storiesbyjo ,

you can use the system data management update jobs 

ChaitanyaILCR_0-1770399827766.png

 

https://www.servicenow.com/docs/r/platform-administration/mark-records-update.html

https://www.youtube.com/watch?v=k4n_W3arIns

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Delete Jobs and Update Jobs in ServiceNow Bulk Update and Bulk Delete Data https://www.servicenow.com/docs/bundle/yokohama-platform-administration/page/administer/managing-data/concept/c_DataManagement.html

Bert_c1
Kilo Patron

Use a Before - Query business rule on sc_req_item. In the script, use

 

if (gs.getUser().isMemberOf('Test Group'))

    return null;

 

Test the above, plenty of examples in your instance.

AlokD6499012040
Tera Guru

1. Use Fix Scripts instead of Background Scripts

While Scripts – Background works, Fix Scripts are the professional choice for Production.

  • Version Control: They are captured in Update Sets, allowing you to move the exact code from Sub-Prod to Production.

  • Review: They provide a record of what was run, by whom, and when.

  • Testing: You can easily run them in "Unload" mode or test them in a lower environment first.

2. Optimize for Performance & Safety

To handle 30,000+ records without "killing" the node or triggering unwanted side effects, use these methods:

  • setWorkflow(false): This is critical. It prevents Business Rules, Workflows, and Notifications from firing. Without this, you might accidentally email thousands of users.

  • autoSysFields(false): This prevents the sys_updated_on and sys_updated_by fields from changing, which is often preferred for "administrative" cleanup to preserve the original audit trail.

  • setLimit(): Test the script on 10 records first, then 100, before running the full batch.

3. The Script Template

var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addQuery('assignment_group.name', 'Test Group');
ritmGr.addActiveQuery(); // Only get currently active records
ritmGr.setLimit(35000); // Safety limit
ritmGr.query();

var count = 0;
while (ritmGr.next()) {
    ritmGr.active = false;
    ritmGr.setWorkflow(false); // Do not trigger Business Rules/Notifications
    ritmGr.autoSysFields(false); // Do not update system audit fields
    ritmGr.update();
    count++;
}
gs.info("Bulk Update Complete. Total RITMs deactivated: " + count);

4. Rollback and Auditing

  • Rollback Context: Since ServiceNow (London+ versions), background and fix scripts generate a Rollback Context. If something goes wrong, you can navigate to sys_rollback_context.list and revert the changes.

  • Export Data First: As an extra safety net, export the list of Sys IDs you intend to change to XML or CSV before running the script.

  • Batching: If you are worried about the transaction timing out, process the records in batches of 5,000 using a scheduled job or multiple script executions.

 

Kindly mark my answer as Correct and Helpful based on the impact.

Regards,

Alok Das