Hi Allen,

Please check the screenshots. I have included the filter condition to check for State Changes to Closed Complete. It is a Before BR for Inserts and Updates.

Hi,

In your addEncodedQuery line, you need to allow some JavaScript there to grab the current object.

The script differs from what you shared in your original post as well...please try to let us know exactly what you are using. With that said, I'm glad my original reply is Helpful as it prompted you to provide screenshots to clarify what is actually going on...

For the adjustment to script see this example:

addEncodedQuery('query_paste_here...document_id='+current.sys_id);


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I'm glad you found an answer that worked for you.

I'd still recommend reviewing my reply as similar suggestions were stated.

I hope at a minimum, it was helpful. Keep in mind that if multiple solutions assisted you, you can accept more than one solution as well 🙂

Take care!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

Ankur Bawiskar
Tera Patron

@Arijit Saikia 

Did you add gs.info() to check if BR ran?

whether query is working fine?

try this

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


//Checks for any Active approval and aborts the update if active
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', current.sys_id).addOrCondition('sysapproval', current.sys_id);
gr.addQuery('state', 'requested');
gr.query();
if (gr.hasNext()) {
gs.addInfoMessage("There are open approvals which must be completed before this record can be closed");
current.setAbortAction(true);
}

})(current, previous);

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

View solution in original post

when i try this, my record still updates, it does not abort. I do receive the message, but it will still update the record. suggestions?