Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Using current.update() in Business rule is not recommended from servicenow due to following reasons-
1. Before- Records will be saved automatically after BR executes so using current.update is redundant
2. After- Triggers all "before" BRs again causing recursion calls and performance issue
3. Async- Same issue as in After
4. Query- current object doesn't exist and will cause error
5. Display- Runs before UI is rendered. Using current.update doesn't make sense.

To avoid such scenarios, a business rule can be configured on the 'sys_script' table will trigger an error message and
block the creation of any new business rule if it detects the use of current.update() within the script.

Runs: onBefore insert.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function executeRule(current, previous /*null when async*/) {
// Check if the script contains 'current.update()'
if (current.script && current.script.toLowerCase().includes('current.update()')) {
var errMsg = "Error: 'current.update()' should not be used in Business Rules.";

// Abort the insert/update operation
gs.addErrorMessage(errMsg);
current.setAbortAction(true);
}


})(current, previous);
Loading