How to force the sys_created_on time when creating a record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 07:21 AM
The below script works with exception to manually forcing the created on date. What I am doing is converting Incidents to Cases by recreating a Case record and transferring all the data over (including the comments and work notes). All the individual pieces are moving over BUT it's taking the current date/time instead of the original one.
On this journal table I am able to double-click in list view to manually set the date to a previous date just fine. In my script, it isn't honoring what I'm telling it to do though. How do I go about setting this field?
var newJrn = new GlideRecord('sys_journal_field');
newJrn.initialize();
newJrn.name = 'sn_customerservice_case';
newJrn.element = 'comments';
newJrn.element_id = cs;
newJrn.sys_created_by = jrn.sys_created_by.toString();
newJrn.sys_created_on = jrn.sys_created_on;
newJrn.value = jrn.value.toString();
var createdJrn = newJrn.insert();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 10:42 AM
Can you check field type of jrn.sys_created_on and let me know if it's Date Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2019 07:28 AM
Look at the documentation of
autoSysFields(false);
It might help
Vinod Kumar Kachineni
Community Rising Star 2022