Update a record without updating its system fields(like sys_updated_by) from workflow

Prudhvi Raj4
Tera Guru

How can we update a record without updating its system fields(like sys_updated_by)?

5 REPLIES 5

JP - Kyndryl
Kilo Sage

Hi Prudhvi,

I would try the "setWorkflow(false)" method before updating the record to prevent the system fields from being updated. 
For example:
 
var gr = new GlideRecord("table_name");
gr.get("record_sys_id");
gr.setWorkflow(false);
gr.field_to_update = new_value;
gr.update();
 
Please test it, I didn’t try it.
 
Regards,
JP

Shashank_18
Mega Guru

Hi Prudhvi,

 

There are two options as mentioned below:

1- You can use current.autosysfields(false) to skip the update of system fields.

2- You can use below code snippet and modify accordingly:

var target = new GlideRecord("table_name");

target.get("sys_id");
target.setValue('field_name', new_value);
target.execute(); or target.update();

 

Hope this will resolve your issue

Regards,

Shashank

Badal Khojare
Mega Sage
Mega Sage

Yes for skipping the update to system fields use autosysfields(false) as mentioned by Shashank. If you need help with entire code please post the snippet here. 

 

Thanks,

Badal.

Please Mark My Response as Correct/Helpful if it helped.
Regards,
Badal Khojare
Community Rising Star 2023