Constantly daily update record in "updated" and "updated by" field possible cause from daily scheduled job script?

bbf3562
Kilo Guru

We have odd minor issue in this group like this,

update.jpg

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?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

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.


View solution in original post

11 REPLIES 11

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Are you groups populated from LDAP?   Or are there daily jobs that update groups?   If so then a scheduled job could be the culprit.   In the scheduled job definition there is a "run as" field that you can populate with a user.


It a daily scheduled job I created only to update numbers in [sys_user_group] on 2 fields "Total of Members" and "Total of Active Member". It is run as "me" in default which is probably why my username show up alot in Updated By on group table.


If you want to keep those fields up to date, I recommend using a business rule that watches for changes on sys_user_grmember. That way as records added/deleted to that many-to-many table, you can keep the counters on the group up to date in real time rather than relying on a nightly script.


When you create a scheduled job your ID gets plugged in automatically.   You could switch it to another user instead so you know its a background job updating the record.   I am hesitant to suggest that you use gr.autoSysFields(false) because you will not know when the groups were updated for audit history purposes unless you truly don't care about the updates done by the scheduled job.