Copying sysiD from old instance to new

SathiskumarD
Tera Contributor

 

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);

 

 

 

1 ACCEPTED SOLUTION

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.

View solution in original post

11 REPLIES 11

Tanushree Maiti
Tera Patron

Hi @SathiskumarD 

 

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);

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Srikanth_9
Kilo Sage

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:

 

If the provided solution is useful/working, please Accept as Solution and hit the Helpful. 
 
Thanks & Regards,
Srikanth Akula.

 

Nishant8
Tera Sage

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

I tried with u_sys_id but it is showing error.

SathiskumarD_0-1779557133382.png