Before Update BR not working as expected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello Community,
I’m facing an issue with a custom Business Rule on the Requested Item (RITM) table and would appreciate your guidance.
I have a Before Update Business Rule that executes when the RITM state changes to Fulfilled. The purpose of this rule is to populate a custom Date/Time field using gs.nowDateTime();
The Business Rule works as expected for most RITMs. However, for a few RITMs, even though the state successfully changes to Fulfilled, the custom Date/Time field remains empty.
I added gs.info(); statements within the Business Rule for debugging. However, no log entries are being generated for the affected RITMs, even though the state change to Fulfilled is completed successfully.
Has anyone experienced similar behavior with RITM fulfillment? Could this be related to fulfillment workflows/flows, execution order, or multiple updates during state transition?
Any suggestions or best practices to ensure the field is populated would be greatly appreciated.
Thank you in advance for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
Hey @MHimabindu
Since your Business Rule is not generating any logs for certain RITMs, the key takeaway is that the rule is not executing at all for those records, even though the state changes to Fulfilled.
This is typically not a script issue, but an execution path issue.
What Could Be Happening
1. Update is Bypassing Business Rules
Some RITMs may be fulfilled via:
- Flow Designer
- Workflow
- Background scripts / integrations
If setWorkflow(false) is used anywhere, it will skip Business Rules entirely, which explains why:
- State is updated
- But no gs.info() logs appear
2. Condition Not Matching Consistently
If your condition is something like:
current.state == '3'
It may fail in some transitions.
Recommended approach:
current.state.changesTo('3')
3. Multiple Updates During Fulfillment
In some fulfillment processes:
- Record is updated multiple times
- Your BR may not run on the update where state actually changes
4. Execution Order / Overwrite
Another Business Rule or Flow may:
- Run after your rule
- Override or clear your field
Recommended Approach
Instead of relying only on a Before Update Business Rule, use a more reliable pattern:
Option 1: After Business Rule
if (current.state.changesTo('3')) {
current.u_fulfilled_date = gs.nowDateTime();
current.update();
}
Option 2: Handle in Flow Designer
If fulfillment is flow-driven, set the field directly in the flow when state = Fulfilled.
Debugging Steps
Add a log at the very top:
gs.info('BR triggered for: ' + current.number);
Check:
- If logs are missing - BR not triggered
- If logs appear - condition/script issue
- Verify this:
- Any Flow/Workflow involved
- Any use of setWorkflow(false)
- Field audit history
******************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @MHimabindu ,
Switch the BR to After Update, add logging inside the script, and test with one of the problematic RITMs. If it still doesn’t fire, trace the fulfillment workflow/flow to see if the state update is happening in a way that bypasses BR execution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8m ago
Hi @MHimabindu
Probable cause could be -
1. Conditions defined in the "When to run" tab of the Business Rule configuration not accurate . Not fulfilling all cases like the case it is failing.
2. Impersonate by other user and check if same thing is happening
3. Add gs.info to check where it is breaking for some scenarios
4.The execution order of Business Rules can affect outcomes, especially if multiple rules operate on the same table and field
Refer similar case here: https://www.servicenow.com/community/developer-forum/before-insert-update-business-rule-not-working-...
