- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2023 09:37 AM
Hi All,
->We have a before update business rule on change request table where we are checking when we don't have incident number added on any of these two related lists "Incident Fixed by Change" or "Incident Caused by Change", it is throwing error.
->But as per the business rule it should trigger only when updating the record, but it is also triggered while insertion.
-> We have checked we haven't used current.update() in any of the before insert/update business rule.
Not sure how it is happening, how to fix this issue? can anyone please suggest?
BR:
(function executeRule(current, previous /*null when async*/) {
var cin = new GlideRecord("incident");
cin.addEncodedQuery("rfc=" + current.sys_id + "^ORcaused_by=" + current.sys_id);
cin.query();
if(!cin.hasnext()) {
gs.addErrorMessage('Emergency changes must have an associated Incident. Please verify you have an associated Incident listed in either \"Incidents Caused by Change\", \"Incidents Fixed by Change\"');
current.setAbortAction(true);
}
})(current, previous);
Thanks,
Saranya
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2023 10:48 AM - edited ‎03-21-2023 10:49 AM
Hi,
You may have other processes that are updating the record, thus, causing this to run (so the record is actually being updated by a later running business rule). You can consider making this business rule run as late as you can so it's last by adjusting the order. Refer to documentation for assistance: https://docs.servicenow.com/en-US/bundle/utah-application-development/page/script/general-scripting/... - you'd need to review your instance for what could be causing this to run and look at your other business rules, etc. Check for any current.update() in your after business rules as well (which shouldn't be there).
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2023 09:53 AM
Hi @Allen Andreas ,
I have used before update business rule only, the "Insert" box is unchecked, still it is triggering while insertion.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2023 10:48 AM - edited ‎03-21-2023 10:49 AM
Hi,
You may have other processes that are updating the record, thus, causing this to run (so the record is actually being updated by a later running business rule). You can consider making this business rule run as late as you can so it's last by adjusting the order. Refer to documentation for assistance: https://docs.servicenow.com/en-US/bundle/utah-application-development/page/script/general-scripting/... - you'd need to review your instance for what could be causing this to run and look at your other business rules, etc. Check for any current.update() in your after business rules as well (which shouldn't be there).
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!