- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 09:22 PM
Hello,
I have a requirement to edit system field "sys_created_on" but since they are OOB system fields and best practice is not to edit these, I decided to create a date/time field "u_creation_date" so that this creation date field can be editable by certain role bearing users and this new field can be used for the reporting purpose.
but since at the start the field is empty, I want the value to be copied from OOB "sys_created_on" field and will edit it later if needed. To copy this I tried below fix script in my PDI first:
var gr = new GlideRecord('u_test_table');
gr.query();
while(gr.next())
{
if(gr.u_creation_date == ''){
gr.u_creation_date = gr.getValue('sys_created_on');
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
}
now, the issues are:
1. The field is not copying exact value as that in OOB created field for few records. How do I copy exact value
2. I should run this fix script on production instance where there will be around 50000 records, will that be okay or will there be any data loss if I do it on production. Is this not recommended? if yes then is there any alternate solution for this?
Please help me with this!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 10:59 PM
Hi
Can you try this
var gr = new GlideRecord('u_test_table');
gr.query();
while(gr.next()){
if(gr.u_creation_date == '')
{
var gdt=new GlideDateTime(gr.sys_created_on);
gr.u_creation_date = gdt;
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}
}
Please Mark it as correct if its helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 10:08 PM
Hi use this in your script to set date value
gr.setValue('u_creation_date ', gr.getDisplayValue('sys_created_on')); // this should give you exact value test run in back ground script first
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 10:23 PM
Hi,
I tried this but same issue occurred.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 10:15 PM
Hi,
Is this happening for few records only? This is because difference in time zones. Records are created by users who are different time zone and you are updating these records then it takes value as per your time zone.
Please try different API's and see if you get expected values.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2022 10:25 PM
Hi,
yes, this is happening for some records only.
Could you please suggest any different APIs and the script part for this?