- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello,
I was trying to do transform map of work type records from old instance(A) to the new instance (B). We need sysIDs to be copied to the new instance. Below is the onBefore transform script. However, this isn't working. Anything wrong with my code? Any help or direction to resolve this would be greatly appreciated.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (action == "insert") {target.setNewGuidValue(source.sys_id); }
})(source, map, log, target);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @SathiskumarD , I'll suggest to create coalesce on the sys_id so that no conflict with the sys_id as you are trying to import something that is supposed to be unique across the platform.
Could you please delete the respective entries from the ServiceNow and try again by keeping the script enabled.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
As per my understanding, if you want to retain the same sys_id rom the old instance, you need to use XML export from the old instance and XML import into the new instance for foundation data migration.
Transform Maps are generally used to create new records (with new sys_id s) or update existing records based on the transform configuration.
Copying sys_id s across ServiceNow instances using a transform map is generally not recommended as a standard practice. It should only be done if there are strict external dependencies (like third-party integrations) or complex parent-child relationships requiring identical pointers
for exceptional cases,
try with this onBefore transform script:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (action == 'insert')
{ target.setNewGuidValue(source.u_sys_id); } })(source, map, log, target);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @SathiskumarD,
Try with the below code:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (action == "insert" && source.u_sys_id) {
target.setNewGuidValue(source.u_sys_id);
}
})(source, map, log, target);
Also, refer the below links:
- how to get the sys_id's to import in a transform m... - ServiceNow Community.
- Solved: How to update sys id from target source using Tran... - ServiceNow Community.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @SathiskumarD, Usually name of the column is u_sys_id, as columns of your staging table to be referred in the script (of course staging table can be referred).
Could you try below script once?
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (action == "insert" && !source.u_sys_id.nil()) {
target.setNewGuidValue(source.u_sys_id);
}
})(source, map, log, target);
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
I tried with u_sys_id but it is showing error.