SetAbortAction is not working in BR

nowitsvashu
Tera Guru

I'm using this br but setabortaction is not working as it shows invalid update but shows the error message

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

	// Add your code here
	var gr = new GlideRecord('incident');
	gr.addQuery('state','!=','7').addCondition('parent_incident',current.sys_id);
	gr.query();
	if(gr.hasNext()){
		gs.addErrorMessage("Please close child incidents.");
		current.setAbortAction(true);
	}

})(current, previous);
5 REPLIES 5

Aniket Chavan
Tera Sage
Tera Sage

Hello @nowitsvashu ,

Please give a try to the modified script below and see how it works for you,

(function executeRule(current, previous /*null when async*/) {
    // Add your code here
    var inc = new GlideRecord('incident');
    inc.addEncodedQuery('parent_incident=' + current.sys_id + '^state!=7');
    inc.query();

    if (inc.hasNext()) {
        gs.addErrorMessage("Please close child incidents.");
        current.setAbortAction(true);
    }
})(current, previous);

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks & Regards,

Aniket.