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

ServiceNowSteve
Giga Guru

Are you firing this inside the global application or a scoped application?

Also what type of script are you running this in?

running it in the global application, is there a scoped app for CMDB/Asset?  I was not aware if there is.

Sai Kumar B
Mega Sage
Mega Sage

Hi Andy,

Is it scoped application? If not Remove gs.info() as it restricts the next line operation for global applications.Usually gs.info() used for scoped apps.Also check the first line properly before semicolon.

Please mark my answer helpful/correct if applicable.

Best regards,

Sai Kumar

Ankur Bawiskar
Tera Patron
Tera Patron

@AndyB5000 

Did you check the BRs which are triggering are present on the Child table of CMDB CI.

Script looks fine

Regards
Ankur

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