Updateding the sys_updated_on field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 03:12 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 03:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 01:19 AM
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);