Business Rule only runs when checkbox is checked but it should always run?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 10:53 AM
I have a simple business rule that adds 2 error values to my and aborts a save. It's a simple script:
(function executeRule(current, previous /*null when async*/) {
current.setAbortAction(true);
var gdt = new GlideDateTime(current.ap_end_of_support_date.toString() + ' 00:00:00');
gdt.addDaysLocalTime(365);
current.ap_end_of_support_date.setError("Error: " + current.ap_end_of_support_date + ' ' + gdt);
current.setAbortAction(true);
current.wpa2_psk_using_aes.setError('Encryption is required');
})(current, previous);
Here's the rule:
Now, when I run it on the form it works fine. If I check the AES true/false checkbox, it stops running the rule. The rule should always run and should always prevent the form submission. Why is it only running based on the checkbox state? This does not make sense.
This is the only business rule defined on the table, which is a custom table inheriting from nothing in a scoped app. The app has only 1 table. Here is an animation of how it is (not) working:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 11:27 AM
mike,
Seeing as how the checkbox field is a boolean, the 'true' in the condition field above your script may be screwing up your BR somehow. If you leave this field blank, the BR should always run (assuming you don't have any conditions set in the condition builder). You should only put something in the Condition field when you want to specify when the BR should NOT run. So, remove the 'true' in your condition. The setAbortAction() will abort the upcoming DB action so you don't need to call it twice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 12:14 PM
Yeah, that boolean in the condition makes no difference whatsoever - I've tried it both ways.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 12:22 PM
Hi there,
Have you tested with a blanc condition? What is the behavior then?
Have you also tried adding debug statements to de business rule to see what is executed? Or tried the debugger?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2019 12:32 PM
I have tested with blank condition - same result.
I have added print statements and used the debugger, and came to the conclusion in my original question:
"If I check the AES true/false checkbox, it stops running the rule."