updateMultiple & setWorkflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 07:32 AM
Hi ServiceNow community,
Does setWorkflow(false) have any impact when using updateMultiple()?
Based on a situation that happened to me yesterday, it seems that the business rules still run even when I used the following code:
var gr = new GlideRecord('sys_user');
gr.addNotNullQuery('<specific field>');
gr.query();
gr.setValue('<specific field>', '');
gr.autoSysFields(false);
gr.setWorkflow(false);
gr.updateMultiple();
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 07:47 AM
Hi,
Based on my understanding if setWorkflow(false) is used the BRs for this transaction should not have run, regardless of using updateMultiple of going in the loop and update all individually.
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 08:17 AM
Hi Anurag,
I appreciate the reply.
The reason why I feel that updateMultiple ignores setWorkflow is due to the situation I had yesterday.
- The code above exists in a Fix Script and it updates a custom field on the sys_user table
- There is an after business rule on sys_user that executes on insert/update and if Active or the custom field changes
- Within the business rule, I write some messages to the log. When I looked at the log at the time I ran the Fix Script, I found the messages from the business rule.
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 08:29 AM
Hi there,
No it should not impact. setWorkflow(false), autoSysFields(false), updateMultiple should work fine.
Also just tested on my PDI to verify: business rules did not got executed with your code (tried on incident to simulate).
Do note: people often mention Business Rules are not triggered with setWorkflow(false). Though this is not 100% correct. There are exceptions!
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 08:46 AM
Thanks for the reply.
Can you explain why the business rule executed? I can't figure it out . I ran the Fix Script in the foreground but I wouldn't expect that to cause it.
As I mentioned in my note, I see the messages from the business rule in the log and I was not expecting those so I'm confused.