Bulk Update Fix Scripts - Work notes should be updated by system user? URGENT

saint
Tera Expert

Hi Experts,

 

I'm writing a bulk closure script for incident and sc tasks, i want to add comments to the tasks as a system user. currently it takes logged in users name. I tried with setJournalField 

 

gr.setJournalEntry('work_notes','TEST','userid');
 
and with
 
setValue('work_notes','TEST','userid');
 
Need urgent assistance.
2 REPLIES 2

jonsan09
Tera Sage

Check this thread on running a scheduled script execution for running as system user: https://www.servicenow.com/community/itsm-forum/scheduled-script-execution-run-as-system-user/td-p/2...

Tanushree Maiti
Mega Patron

Hi @saint 

 

autoSysFields(false): It is a GlideRecord method used in scripts to prevent system metadata fields—such as sys_updated_on, sys_updated_by, and sys_mod_count—from being updated when a record is modified. It is commonly used for data fixes or silent updates to avoid altering record history

 

Also few  tips when running fix scripts to update records in bulk :

Test in Sub-Prod: Run this script in a lower environment (Dev/QA) first.

setWorkflow(false): This prevents triggering unnecessary notifications, SLA updates, or related Business Rules.

Use setLimit(100): Initially, only update a small batch like 50/100 to ensure the code behaves as expected.

autoSysFields(false)

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: