- 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:57 AM
Hi,
those 3 fields are of what type?
I would suggest to use before update BR and don't use current.update() in BR
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:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2022 08:34 AM
try this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if (current.u_inactive_kernels.toString() == '0' || current.u_non_running_services.toString() == '0' || current.u_not_exploitable_due_to_configuration.toString() == '0' )
{
current.u_ignore = 1;
}
})(current, previous);
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:49 AM
I suggested to use Before BR and not After BR
Try above script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader