Business Rule does not abort State advancement

lbless1
Giga Expert

I have a BR to require an attachment, however it is not preventing the State from progressing.

 

lbless1_0-1771372671079.png

 

(function executeRule(current, previous) {

// Only enforce when moving to Screening
if (current.state == '3' && previous.state != '3') {

var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id', current.sys_id);
att.addQuery('table_name', 'dmn_demand');
att.setLimit(1);
att.query();

if (!att.hasNext()) {
gs.addErrorMessage('At least one attachment is required before moving to Screening.');
current.setAbortAction(true);
}
}

})(current, previous);
1 REPLY 1

Brad Bowman
Kilo Patron

The Filter Conditions covers when you want the script to run, so you don't need this script wrapped in an if statement that might not ever be true(is the value the number 3 or the string '3'???)