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

@AndyB5000 

can you try this script

var queryStringCI = 'asset_tag=AF268729';
var CIchg = new GlideRecord('cmdb_ci_netgear');
CIchg.addEncodedQuery(queryStringCI);
CIchg.setLimit(10);
CIchg.query();
CIchg.setWorkflow(false);
while(CIchg.next()){
CIchg.sys_class_name = 'cmdb_ci_ip_switch'; //table name of class changing too
CIchg.update();
}

Please mark my answer as helpful/correct, if this solves your issue.

Regards,

Sai Kumar

 

Marcel Horn
Tera Expert

Hi Andy,

I think current.setWorkflow(false) makes no sense, because you use a GlideRecord and not the current data record.

Maybe you can try setWorkflow(false) before you start the query.


var CIchg = new GlideRecord('cmdb_ci_netgear');
CIchg.addEncodedQuery('asset_tag=AF268729');
CIchg.setLimit(10);
CIchg.setworkflow(false);
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.update();
}

 

Regards
Marcel

 

Fabio20
Tera Contributor

Hello did you find an answer for this ? I encounter the same issue.

Thanks

Dawid K1
Tera Contributor

It seems that the .setWorkflow(false) does not work when reclassifying records. I've encountered the same issue while working with .updateMultiple() and it behaves in the same way. More details in the other thread.

updateMultiple & setWorkflow - ServiceNow Community