Export and Import XML - Date/Time Stamps occur in past
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 11:41 AM
When Exporting records via XML from one instance and importing into another instance to preserve sys_ids, the Created and Update Date/Time stamps are identical from the source system. This drives the Reporting people nuts because in Snow Mirror (and the target instance) the date/time stamps are in the past rather than being the actual date/time imported.
Has any one else run into this concern?
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 12:31 PM
Instead of doing direct XML imports of the data, can you do an XML Import Set and transform map? That should give you control of those dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 12:38 PM
Thanks Adam, I'll have to read up on that. I do know that this activity is being performed in the times when keeping the sys_id of the record intact between instances is important. We already do .xlsx templates and transform maps for a great deal of different types of data when it is not important to keep sys_ids in sync or we are assigning instance specific unique identifiers via the Transform map and xml import is not advised.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 12:43 PM
To retain the sys_id in a transform map (from an XML import or other), see this example:
Add onBefore scripts to the transform map
The transform map gives you all the control over what to load or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 12:58 PM
Thanks Adam! I'll make this recommendation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2018 08:13 PM
As suggested above, if u were you i will perform the below:
Create one onBefore transform map script to copy the sys_id of new records from the source to the target instance. Create a second onBefore transform map script to identify records on the target instance that have the same unique values but different sys_id values.
- Open the table transform map record you just created.
- In the Transform Scripts related list, click New.
- In the When field, select onBefore.
- Enter the following Script:
if (action == "insert" ) {target. setNewGuid (source. u_sys_id ) ; }
- Click Submit.
- In the Transform Scripts related list, click New.
- In the When field, select onBefore.
- Enter the following Script:
/** * This script queries for a uniquely identifying value of the referenced record and then * updates the target reference field with the sys_id of the matching target record. * This sample assumes: * 1) The target table contains an assigned_to field which is a reference field. * 2) The reference field references the User [sys_user] table. * 3) You can use the email field to uniquely identify users. Alternatively you * could use the user_name field. */ var ref = new GlideRecord("sys_user"); //Replace sys_user with any reference table ref.addQuery("email", source.email); //Replace email with any unique field ref.query(); if(ref.next()){ target.assigned_to = ref.sys_id; //Replace assigned_to with any reference field }
- Click Submit.