current.setabortaction not working

Raze00
Tera Contributor
(function executeRule(current, previous /*null when async*/) {

    var x = new GlideRecord('incident');
    x.addQuery('parent_incident', current.sys_id);
    x.query();
    if(x.next()){
        if(x.state=='7'){
            gs.addInfoMessage('This is a child incident and the state is closed');
            current.setAbortAction(false);
        }
        else{
            gs.addErrorMessage('The child incident is not closed first close that');
            current.setAbortAction(true);
        }
    }
   
    // Add your code here

})(current, previous);
 
 
 
in this script the true part of the setabortaction is not working. the form gets updated even if it shows invalid update and the error message in the script. can anyone suggest any solution why this might be happening?
1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Raze00 

your business rule is on which table?

if it is going inside the error message then it should abort

If my response helped please mark it correct and close the thread so that it benefits future readers.

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