setWorkflow(false) not working in script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 07:52 AM
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
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 09:23 AM
the BR's appear on the lower tables in the CI hierarchy...example cmdb_ci_computer, cmdb_ci_server.
Because the BR does not appear at the cmdb_ci level prevent the line from stopping the BR's from running.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 09:51 PM
That's correct it might be disabling only the Parent BR and not the child BRs
Why not do this
1) for each while get the class name and then query that table with the asset tag and then use setWorkflow(false) just before the update
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 08:47 AM
Ankur,
Makes sense, so I modified the code down to the child tables and the BR still triggered. The record is currently classified as Network Gear and is changing to IP Switch. When I run the below script the BRs still trigger.
var queryStringCI = 'asset_tag=AF268729';
var CIchg = new GlideRecord('cmdb_ci_netgear');
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.
Andy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 09:31 PM
If there are any BRs on the child table then they should stop
There is mistake in your function name
Try this and it should work fine
var queryStringCI = 'asset_tag=AF268729';
var CIchg = new GlideRecord('cmdb_ci_netgear');
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();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2021 05:58 AM
still did not work, updated the line to show setWorkflow(false); and ran the script as a background script with the glide record calling the table the BR resides on and it still triggers the BR.