top of page

Stopping Business Rule Processing in ServiceNow Background Scripts

  • kelly.ryu
  • Mar 20
  • 2 min read

Updated: Mar 29

ServiceNow business rules are server-side scripts that execute whenever a record is displayed, inserted, updated, or deleted (or even queried) in the platform. They allow developers to automate processes such as setting default values, enforcing data consistency, or triggering notifications when data changes.


However, when running a background script to modify a large number of records, these business rules can become problematic. A bulk update script might inadvertently trigger numerous rules on each record, leading to unintended side effects and slow performance. For instance, one administrator’s background script to update 2,000 change records ended up firing business rules unexpectedly, even resetting all approvals on those records. Such issues can disrupt workflows and impact data integrity.

To prevent these unintended side effects, it is crucial to bypass business rule execution when performing bulk updates.


Understanding Business Rule Execution in ServiceNow


Under normal circumstances, whenever a record is updated, ServiceNow automatically triggers any associated business rules. These rules can include validation checks, data transformations, or notifications.


For bulk updates, however, executing business rules can be inefficient and unnecessary. Large tables like Incident or Change may have hundreds of business rules. Running all those scripts for each record in a bulk operation can significantly slow down the process and may introduce unintended changes, such as altering timestamps, resetting workflows, or sending redundant notifications.


How to Prevent Business Rule Execution


ServiceNow provides methods to control business rule execution in background scripts. The GlideRecord API offers two essential functions for this purpose:


  • gr.setWorkflow(false); – Prevents any business rules or workflows from running during the update.

  • gr.autoSysFields(false); – Prevents the system from updating Updated and Updated by fields.


Step-by-Step Implementation


  1. Initialize a GlideRecord query for the target table.

var gr = new GlideRecord("change_request");
gr.addQuery("state", 3); // 3 = Closed state
gr.query();
  1. Loop through the result set and update records.

while (gr.next()) {
	gr.work_notes = "Bulk update: adding a work note to closed change"; 
	gr.autoSysFields(false);   // Prevents updating system fields
	gr.setWorkflow(false);     // Disables business rule execution        				  			   
	gr.update();               // Saves the record
}

This script updates all closed change requests while preventing unnecessary business rule execution and system field updates.


Alternative Approaches and Best Practices


  • Use GlideRecord.updateMultiple() for efficiency:

var gr = new GlideRecord("change_request");
gr.addQuery("state", 3);
gr.setValue("work_notes", "Bulk update: work note added"); gr.updateMultiple();
  • This method updates all records at once without iterating through them individually, reducing processing time.

  • Use conditional business rules: Add conditions to business rules to exclude background processes by using gs.isInteractive() to ensure they run only during user interactions.

  • Batch processing for large datasets: When dealing with thousands of records, consider updating in batches to prevent system performance degradation.

  • Test in a sub-production instance: Always validate your script in a non-production environment before applying changes to the live system.


Disabling business rules during bulk updates in ServiceNow improves efficiency and prevents unintended side effects. Using setWorkflow(false) and autoSysFields(false), developers can gain better control over background scripts while maintaining data integrity. By applying best practices, ServiceNow administrators can safely execute large-scale updates while minimizing risk and ensuring optimal performance.


CONTACT

New Zealand HQ

Integrated Knowledge Consulting Office

Level 3, 93 Grafton Road

Auckland

South Korea

Integrated Knowledge Consulting Office

BMY역삼타워 6층

서울특별시 강남구 역삼동 678-10번지

 

info@ikconsulting.com

Thanks for submitting!

  • LinkedIn Social Icon

© Copyright 2025 Integrated Knowledge Consulting. All rights reserved.

bottom of page