Alternatives to current.update() in Business Rules: Impact and Best Practices?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 12:29 AM
Hi Community ,
I understand that using current.update() in a Business Rule is generally not considered a good practice. However, I have a requirement where it seems necessary to use current.update(). While I know we can use setWorkflow(false) to mitigate some issues, it has a significant impact on various components such as:
- Audit records
- Journal fields
- Workflow engine
- Notification engine
Given this, I have two specific questions:
If I glide the same record in an after Business Rule (using a GlideRecord query) and then update it, will it have the same impact as using current.update()?
If I call a Script Include from the Business Rule, pass the current object to it, and then glide the same record in the Script Include to update it, will that also have the same impact?
Finally, if both options have the same impact, is there any alternative method to update the current record without using setWorkflow(false) and avoiding these side effects?
Thanks in advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 01:15 AM
Hello @Astik Thombare
For both cases, the impact will be the same as using current.update() unless you explicitly manage workflows, audits, and notifications.
The best approach in such scenarios is to use setWorkflow(false) to mitigate unwanted side effects.
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 01:31 AM
Using gr.update() on the same record in an after Business Rule will have a similar impact to using current.update(). It will trigger the same Business Rules and other automations, potentially causing recursive loops or unexpected behavior.
Calling a Script Include and updating the record there will also have the same effect. The location of the update doesn't change its impact on the system.
- Alternatives to avoid side effects: If you want to update the record without side effects, consider the following alternatives:
I don't recommend it though...
Flag to prevent recursion: Add a flag to the record to indicate that the Business Rule should not trigger again for this update. Example:
if (!current.skip_update) {
current.skip_update = true;
current.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 06:08 AM
Hi @Astik Thombare - It might be helpful to share your requirement so the community can suggest potential solutions. For example, one option is to use GlideAuditor to manually create audit records when setWorkflow(false) is used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 11:24 AM - edited 01-25-2025 05:17 PM
There is the 'disableAutoSysFields API that prevents update to any 'sys' fields.
I have some scripts from the past where I used 'autoSysFields(false)' on a GlideRecord Object. Can't seem to find it documented any where at the moment.
However the OOB script include 'NumberManager' for one uses 'autoSysFields(false)' at line 98. And 'AssessmentUtils at line 253.