What It Does
The setWorkflow() method controls Business Rule execution for a specific GlideRecord instance. When you call setWorkflow(false), ServiceNow bypasses all Business Rules that would normally fire during insert(), update(), or deleteRecord() operations on that record.
Internally, ServiceNow sets a flag on the GlideRecord object that the database layer checks before triggering Business Rules. This affects all types of Business Rules: before, after, async, and display. The suppression applies to the current GlideRecord instance only and persists for the lifetime of that object. Other GlideRecord instances remain unaffected.
The method returns void and cannot fail. There's no return value to check because the operation simply sets an internal flag. The workflow setting takes effect immediately and applies to all subsequent database operations on that GlideRecord instance.
The method only affects Business Rules, not other platform mechanisms. ACLs, audit logging, and field validation still execute normally. Notifications triggered directly by Business Rules won't fire, but notifications configured through other means remain unaffected. UI policies and client scripts don't apply since this is a server-side API.
Related methods include autoSysFields() which controls system field updates, and setUseEngines() which controls multiple platform features at once. Unlike setUseEngines(false), setWorkflow(false) provides granular control over just Business Rules.
When to Use This
Use setWorkflow(false) during data migrations, bulk imports, or administrative cleanup operations where Business Rules would interfere with the process. This includes scenarios where Business Rules might trigger notifications, create unwanted child records, or perform expensive calculations that aren't needed during bulk operations. It's also essential when correcting data where Business Rules might prevent necessary updates or cause infinite loops.
Avoid this method for regular application logic where Business Rules should execute normally. If you need to bypass specific Business Rules rather than all of them, modify the Business Rule conditions instead. For broader control over platform features, use setUseEngines(false) which disables Business Rules, audit logging, and other platform mechanisms simultaneously.
Return Value
The method returns void and has no failure conditions to handle. The workflow setting is applied immediately to the GlideRecord instance, and there's no indication of success or failure because the operation cannot fail. Don't attempt to chain this method or use its return value in conditionals.
Enjoying this? Get one deep-dive per week.
Join 1,000+ ServiceNow pros — scripts, GlideRecord patterns, Flow Designer techniques, and career moves. Free.
Platform Behavior & Side Effects
- Business Rules (before, after, async, display) are completely bypassed when workflow is disabled
- ACLs continue to execute normally and can still prevent database operations
- Audit logging behavior depends on system configuration and may still occur
- Performance improves significantly during bulk operations since Business Rule processing is skipped
- Notifications triggered by Business Rules won't fire, but other notification mechanisms remain active
- Field validation and data integrity checks at the database level still apply
- The setting persists for the lifetime of the GlideRecord instance but doesn't affect other GlideRecord objects