Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

setWorkflow(false) not working in script

AndyB5000
Mega Guru

I have a script that we use that allows us to quickly reclassify CIs, basically move them from one table to another, and I am using the line setWorkflow(false); to prevent the business rules from triggering, but for some reason it is not working and the BRs are firing anyways..

 

var queryStringCI = 'asset_tagINAF268729,AF268723,ADM00117,10794812,10794187,10657191,10657190,';
var CIchg = new GlideRecord('cmdb_ci');
CIchg.addEncodedQuery(queryStringCI);
CIchg.setLimit(10);
CIchg.query();
gs.info("----CMDB\t" + CIchg.getRowCount());
while(CIchg.next()){
CIchg.sys_class_name = 'cmdb_ci_ip_switch'; //table name of class changing too
CIchg.setWorkflow(false);
CIchg.update();
}

Thanks in advance for the assistance...

Andy

18 REPLIES 18

Hi,

Strange.

Seems you need to raise HI ticket

Regards
Ankur

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

Ian Mildon
Tera Guru

It is normally used in the format:

current.setWorkflow(false);

And is intended to prevent recursion happening when the following is used in a Business Rule:

current.update();

So as you are not running a "current.update();" you shouldn't really need to do anything to the workflow (which has a syntax error anyway, as it should be in camelcase with a W).

AndyB5000
Mega Guru

If I change the workflow line to current.setWorkflow(false); the script fails.

this has been confused..makes no sense.

 

find_real_file.png

Hi@AndyB5000 

use current.setWorkflow(false) in BR.

In fix script you can’t give current object directly.

I tried that, check the screenshot in my previous post.  Changing it to current.setWorkflow(false) does not work as the BR still triggers.