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 created.
-
In the Transform Scripts related list, click
New.
-
In the When field, select
onBefore.
-
Enter the following script:
if (action == "insert") {target.setNewGuidValue(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.