---
sourceDocument: Brazil Workflow Data Fabric
sourceDocumentLink: https://www.servicenow.com/docs/r/integrate-applications

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil Workflow Data Fabric

ft:clusterId :

    - crint

bundleId :

    - crint

workflow :

    - Creator


---

# Add onBefore scripts to the transform map

# Add onBefore scripts to the transform map {#ariaid-title1}

릴리스 버전: Brazil  
업데이트 날짜 2026년 09월 10일  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 2분  
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.

## 시작하기 전에

Role required: admin.

## 프로시저

1. Open the table transform map record you created.
2. In the Transform Scripts related list, click New.
3. In the When field, select onBefore.
4. Enter the following script:  

       if (action == "insert") {target.setNewGuidValue(source.u_sys_id); }

5. Click Submit.
6. In the Transform Scripts related list, click New.
7. In the When field, select onBefore.
8. 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
       }

9. Click Submit.
**이전 주제:** [Create a transform map](https://www.servicenow.com/docs/7TDMHrqAs9AK6EV7EmKfoQ "A transform map is a set of field maps that determine the relationships between fields in an import set and fields in an existing ServiceNow table, such as Incidents [incident] or Users [sys_user].")  
**다음 주제:** [Retrieving data from a CSV formatted file](https://www.servicenow.com/docs/gd34OUdk7c6lWPahQUhUIQ "In this method, you import data from another instance using an HTTPS data source to return a CSV formatted file containing the rows to be imported.")

