- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 07:52 AM
Good morning community,
Trying to track down unexpected results from a change that went in and hoping for a sanity check.
We have a business rule that checks for a value of 0 on three fields (insert and update), and if correct, will set an IGNORE flag to 1 (true).
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (current.u_inactive_kernels == 0 || current.u_non_running_services == 0 || current.u_not_exploitable_due_to_configuration == 0 )
{
current.u_ignore == 1;
current.update();
}
})(current, previous);
However, when the values of those three fields was set to <empty>, it appears to have triggered the IGNORE flag-
Is this expected? If so, how to prevent this since we are checking for if the value with '==' operator already. Is ZERO the same as <empty>?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 08:34 AM
What is the condition of the BR?
You can append the existing condition and add this with AND Operator that <FIELD ><IS NOT EMPTY>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 07:23 PM
Would you mind marking appropriate response as correct and close the thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 08:34 AM
What is the condition of the BR?
You can append the existing condition and add this with AND Operator that <FIELD ><IS NOT EMPTY>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 08:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 09:06 AM
You should add the condition, I'm sur you don't need to run the BR on each DB transaction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2022 12:08 PM
We have gone with your solution on this for now, as you are correct that with the conditions it not only prevents the <empty> issue from happening, but also limits greatly the number of records touched.
We have since had major failures however, prod instance crashing two days running now, due to memory spike issue after scanning was enabled on workstations and AWS and other virtual desktops. Slow in responding back due to that fun, but thank you all for the help on this.