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-05-2021 06:13 AM
Hi,
Strange.
Seems you need to raise HI ticket
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:54 AM
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).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 10:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 10:41 AM
Hi
use current.setWorkflow(false) in BR.
In fix script you can’t give current object directly.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 10:49 AM
I tried that, check the screenshot in my previous post. Changing it to current.setWorkflow(false) does not work as the BR still triggers.