Updateding the sys_updated_on field

Eli Guttman
Tera Guru

Hi,

 

is there a way to update the "updated" system field "sys_updated_on" using a script?

 

The use case is that we are importing records from external system, and would like to set the update date same as the source system.

this is done using import set and transform map.

 

Is there a way to update the "sys_updated_on" field or we must use another date field? i know that there is an option to use 

 

gr.autoSysFields(false);

But not sure where i can use it as part of the fields mapping in the transform map.

2 REPLIES 2

Harshal Aditya
Mega Sage
Mega Sage

Hi @Eli Guttman ,

 

Hope you are doing well.

 

Please use below logic to update sys_updated_on field

var updateInc = new GlideRecord("incident");
updateInc.get("incident sys_id"); // Replace with incident record sys_id
updateInc.sys_updated_on = "2023-02-21 07:25:46";
updateInc.autoSysFields(false);
updateInc.update();

 

Note : You would need to modify the logic to make it usable in the transform map.

 

Also this is not the best practice 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0859763

 

Please Mark My Response as Correct/Helpful based on Impact

Regards,
Harshal

Eli Guttman
Tera Guru

Thank you Harshal.

yes, i did something similar - i placed it in the on after transform map script so i can use the target object for the autoSysFields(false);