변환 맵에 onBefore 스크립트 추가

  • 릴리스 버전: Zurich
  • 업데이트 날짜 2025년 07월 31일
  • 소요 시간: 1분
  • 새 기록의 sys_id 소스에서 대상 인스턴스로 복사하는 onBefore 변환 맵 스크립트를 하나 만듭니다. 고유 값은 같지만 sys_id 값이 다른 대상 인스턴스에서 기록을 식별하는 두 번째 onBefore 변환 맵 스크립트를 만듭니다.

    시작하기 전에

    필요한 역할: admin.

    프로시저

    1. 생성한 테이블 변환 맵 기록을 엽니다.
    2. 변환 스크립트 관련 목록에서 새로 만들기를 클릭합니다.
    3. 시기 필드에서 onBefore를 선택합니다.
    4. 다음 스크립트를 입력합니다.
      if (action == "insert") {target.setNewGuidValue(source.u_sys_id); }
    5. 제출을 클릭합니다.
    6. 변환 스크립트 관련 목록에서 새로 만들기를 클릭합니다.
    7. 시기 필드에서 onBefore를 선택합니다.
    8. 다음 스크립트를 입력합니다.
      /** 
      * 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. 제출을 클릭합니다.