Business Rule - IF condition checking for ZERO triggering on <empty>?

jlaps
Kilo Sage

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-

find_real_file.png

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>?

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

What is the condition of the BR?

You can append the existing condition and add this with AND Operator that <FIELD ><IS NOT EMPTY>

-Anurag

View solution in original post

9 REPLIES 9

@jlaps 

Would you mind marking appropriate response as correct and close the thread.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Anurag Tripathi
Mega Patron
Mega Patron

What is the condition of the BR?

You can append the existing condition and add this with AND Operator that <FIELD ><IS NOT EMPTY>

-Anurag

Conditions are nil basically, every time it is updated/inserted-

find_real_file.png

You should add the condition, I'm sur you don't need to run the BR on each DB transaction.

-Anurag

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.