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

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.


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?


Anurag Tripathi
Mega Patron
Mega Patron

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


find_real_file.png


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.


-Anurag

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?


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();  


      }