- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2017 12:41 PM
We have odd minor issue in this group like this,
Notice that in red circle was recently updated by me but I never touch that group. I was wondering if that was cause by daily schedule job script created by me that run on [sys_user_group] table to update some value in specific fields that cause trigger on audit update? If so then will use gr.setWorkflow(false); in script work to prevent that audit trail updated and updated by?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2017 01:13 PM
Hi Bradley,
It is very likely that your scheduled job is doing this. Rather than setWorkflow(false), try autoSysFields(false).
setWorkflow() controls whether business rules and workflows will be triggered when the record is updated.
autoSysFields() determines if the times, counts, (and I believe updated by) are updated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2017 01:13 PM
Hi Bradley,
It is very likely that your scheduled job is doing this. Rather than setWorkflow(false), try autoSysFields(false).
setWorkflow() controls whether business rules and workflows will be triggered when the record is updated.
autoSysFields() determines if the times, counts, (and I believe updated by) are updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2017 05:29 AM
Thanks for pointing out to right code. Do I put setWorkflow(false) in executing query while loop every time it update row table or I put that code before the while loop?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2017 03:24 PM
Hi Bradley,
Here are a couple of things i always keep in mind while creating / running a scheduled job or fix script
1) Run As
I always try to keep it as system admin as i dont what my name against those records(like you pointed)
2) SetWorkflow(false)
I always try to see if i can include this in my transaction , depending on whether i need the BRs to run or not. THis has its own performance benefits
3) autoSysFields(false)
Although by changing the 'run as' i can manage with updated by, but still there are other fields that i dont want to be updated like updated on, etc. Si its recommended to turn this off.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2017 05:31 AM
Wow this is wonderful description to know the difference between SetWorkflow(false) and autoSysFields(false). Thanks for explanation. Do you put autoSysFields(false) in loop during DB executing query each row or before the loop?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2017 05:37 AM
If you choose to use autoSysFields(false), then yes, it would go inside a loop.
var rec = new GlideRecord('some_table');
rec.addQuery('active', true); // example
rec.query();
while (rec.next()) {
rec.autoSysFields(false); // do not update automatic fields - leave no footprints
rec.update();
}