- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 03:10 AM
Hi,
By any chance if i want to update the created on date how can i do that
I tried with below background script but it is not updating
var usr = new GlideRecord('sys_user');
usr.get("SYSID");
usr.query();
usr.sys_created_on = '2020-01-01';
usr.update();
When i see the background it is displaying as sys_trigger insert but when i see the user record it is not updateing
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 03:16 AM
Hi Shaik,
The sys_created_on field is a GlideDateTime field. Please use the below script:
var gdt = new GlideDateTime('2020-01-01 07:00:00');
var gr = new GlideRecord("sys_user");
gr.addQuery('sys_id', '1234546344354543543');
gr.query();
if (gr.next()){
gr.sys_created_on = gdt;
gr.autoSysFields(false); // Do not update sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on
gr.setWorkflow(false); // Do not run any other business rules
gr.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 03:16 AM
Hi Shaik,
The sys_created_on field is a GlideDateTime field. Please use the below script:
var gdt = new GlideDateTime('2020-01-01 07:00:00');
var gr = new GlideRecord("sys_user");
gr.addQuery('sys_id', '1234546344354543543');
gr.query();
if (gr.next()){
gr.sys_created_on = gdt;
gr.autoSysFields(false); // Do not update sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on
gr.setWorkflow(false); // Do not run any other business rules
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 03:35 AM
Hi Shaik,
Would like to know the purpose for changing the value to some other value
also sys_created_on is date/time so you need to set the date/time and not only date
var usr = new GlideRecord('sys_user');
usr.get("SYSID");
usr.sys_created_on = new GlideDateTime('2020-01-01');
usr.update();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2020 03:37 AM
Hi,
try this with the proper value of sys_created_on field:
var dt = new GlideDateTime('2020-04-07 07:00:00');
var gr = new GlideRecord("sys_user");
gr.addQuery('sys_id', '234156784323');
gr.setLimit(1);
gr.query();
if(gr.next())
{
gr.sys_created_on=<new value>;
gr.update();
}
Kindly mark it correct and helpful.
Thanks,
Priyanka