Transform map - mapping of u_sys_created_on to target table sys_created_on

Trupti Krishnam
Tera Contributor

I have requirement where i have to map  source .sys_created_on from the import set table to the target table 

 

I have tried it by field mapping - but after checking it by running the transform map it is showing as empty

 

so i have written a script  - ON Before Script - 

target.sys_created_on = source.u_sys_created_on;
target.sys_created_by = source.u_sys_created_by;
 
 this also gave as empty in the target table field
 
 
2. I tried it by giving Glide date and time
 
var created_on = new GlideDateTime(source.u_sys_created_on);
var updated_on = new GlideDateTime(source.u_sys_updated_on);
 target.sys_created_on = created_on.getByFormat('MM/dd/yyyy hh:mm:ss a');
 target.sys_updated_on = updated_on.getByFormat('MM/dd/yyyy hh:mm:ss a');
 
expected is : - 1/28/2025 6:03:00 AM
what i 'am getting is : - 1/27/2025 19:00:00
Please help me in getting the expected result on sys_created_ on   and    sys_updated_on  on the target fields
thanks!
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Trupti Krishnam 

what does the source file contain?

what error you are getting after data load? is the data not getting reflected on those 2 tables?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Rafael Batistot
Tera Sage

Hi @Trupti Krishnam 

 

You’re trying to set the system fields sys_created_on and sys_updated_on on the target table during an import via Transform Map, but these fields are read-only by default in ServiceNow, and cannot be modified using direct assignment (even in transform scripts).

 

You need to disable auto-setting of system fields using this setting:

 


In the 
Transform Map

Add the following in a “OnBefore” transform script:  

 

target.setWorkflow(false); // Disables business rules
target.autoSysFields(false); // Allows writing to sys_created_on, sys_updated_on

target.sys_created_on = new GlideDateTime(source.u_sys_created_on);
target.sys_created_by = source.u_sys_created_by;

target.sys_updated_on = new GlideDateTime(source.u_sys_updated_on);
target.sys_updated_by = source.u_sys_updated_by;