케이스 생성 구성요소 인스턴스 구성

  • 릴리스 버전: Australia
  • 업데이트 날짜 2026년 03월 12일
  • 소요 시간: 10분
  • 사용자가 웹 사이트에 포함시켜 웹 사이트의 제품 및 서비스와 관련된 문제를 직접 해결할 수 있도록 케이스 생성 구성요소 인스턴스를 구성합니다.

    시작하기 전에

    케이스 생성 구성요소를 구성하려면 다음 설정이 있어야 합니다.

    필요한 역할: sn_embeddable_core.emb_admin

    프로시저

    1. 다음으로 이동 모두 > Web Embeddable > 홈페이지.
    2. 홈페이지에서 모듈 만들기를 선택하거나 기존 모듈을 사용합니다.
      새 모듈 생성에 대한 자세한 내용은 다음 문서를 참조하십시오 모듈 생성.
    3. 모듈 페이지의 구성요소 탭에서 케이스 생성 구성요소 인스턴스를 기존 또는 새 그룹에 추가합니다.
      그룹을 만든 다음 구성 요소 인스턴스를 추가하는 방법에 대한 자세한 내용은 을 참조하십시오 그룹 생성 및 구성요소 인스턴스 추가.
    4. 옵션: 라이브 미리 보기를 사용할 수 없는 경우 정적 미리 보기 표시 옵션을 전환하여 구성요소 인스턴스의 시각적 표현을 확인합니다.
      주:
      활성화하면 전역 속성 또는 구성요소 속성에 대한 변경 사항이 미리 보기 탭에 실시간으로 표시되지 않습니다.
    5. 케이스 생성 구성요소 인스턴스 속성을 구성합니다.
      • 미리 보기 탭에는 구성요소 속성에 설정된 선택 항목에 따라 실시간 데이터가 표시됩니다.
      • 케이스 생성 구성 요소 인스턴스와 관련된 구성요소 속성에 대한 설명은 문서를 참조하십시오 케이스 생성에 대한 구성요소 속성.
    6. CORS 규칙 탭을 선택하여 CORS 규칙을 구성합니다.
      CORS 규칙 구성에 대한 자세한 내용은 다음 문서를 참조하십시오 구성요소를 포함 ServiceNow 하기 전에 CORS(Cross-Origin Resource Sharing) 규칙 구성.
    7. 구성 요소 탭을 선택합니다.
      애플리케이션 범위에 대한 메시지가 나타나면 범위를 고객 서비스용 웹 구성 요소로 변경하여 기록을 편집할 수 있도록 합니다.
    8. Embed 코드 가져오기를 선택합니다.
      전역 코드와 구성요소 코드가 모두 표시되는 팝업 창이 나타납니다.
    9. 전역 코드 탭에서 생성된 코드를 검토하고 전역 코드 복사를 선택합니다.
      전역 코드는 외부 공급업체 웹 페이지에 한 번만 추가해야 합니다.
      import { init, login, logout, startGuestSession } from 'https://demo.servicenow.com/uxasset/externals/sn_embeddable_core/index.jsdbx';
      
      await init({
          theme: 'fad87d2ca304121029a4d1aed31e610f',  /* sys_id of the theme to use for the embeddable components in your website */
          baseURL: 'https://demo.servicenow.com', /* Base URL of the instance to be used for the embeddable components in your website */
          authCallback: getTokenCallBack, /* Function which returns the auth token for the current user, required for auth setup */
          module: '591800ffc1243610f87714367ed47c6a', /* Demo module */
          pageName: document.title, /* Uses the browser's document title as the page name in User analytics experience */
          guestTokenCallback: getGuestJWTTokenCallBack, /* Function which returns the guest token for the current user, required for guest validation setup */
          cacheComponents: [] /* Pre-caches resources for improved performance. Update component list as per your usage */
      });
      
      function getTokenCallBack() {
          var idToken; /* Get the id token for the current user */
          return Promise.resolve(idToken);
      }
      
      function getGuestJWTTokenCallBack() {
          var guestToken; /* Get the guest token for the current user */
          return Promise.resolve(guestToken);
      }
      
      /* Uncomment below function to handle guest session */
      // await startGuestSession();
      
      /* Uncomment below functions to handle login and logout once the user logs into your website */
      // await login();
      // await logout();
      
    10. 옵션: 구성 요소 코드 탭에서 이벤트 처리기 사용 토글 스위치를 밀어 웹 페이지의 사용자 상호 작용에 의해 트리거되는 이벤트를 처리합니다.
      주:
      이벤트 핸들러를 활성화하면 구성요소 코드도 수정됩니다. 의 이벤트 핸들러 Web Embeddables에 대한 자세한 내용은 다음 문서를 참조하십시오 케이스 생성 구성요소의 이벤트 핸들러.
    11. 구성요소 코드 탭에서 생성된 코드를 검토하고 구성요소 코드 복사를 선택합니다.
      이 생성된 코드에는 이벤트 처리기도 포함됩니다.
      <!--  
          Module: Demo module
          Group: Group 1
          Instance: Case create 1
      -->
      <sn-embedx-case-form
      	sys-id="de45c412c312310015519f2974d3ae1b"
      	confirmation-text="Case submitted successfully!"
      	confirmation-sub-text="Estimated resolution in 24 hours"
      	reference-number-label="Reference Number :"
      	primary-button-label="View details"
      	secondary-button-label="Browse services">
      </sn-embedx-case-form>
      <!--
       The component also includes the following additional properties:
       hide-reference-number
       hide-primary-button
       hide-secondary-button
       hide-record-created-confirmation
       hide-errors
       hide-notifications
      -->
      
      <script type="module">
      	import { getEmbeddables, setEvents, setProperties } from 'https://demo.servicenow.com/uxasset/externals/sn_embeddable_core/index.jsdbx';
      	
      	const snEmbedxCaseForm = document.querySelector('sn-embedx-case-form');
      
      	/* Uncomment this code for the default behaviour of the Case create component.
      
      	// Get the record producer record id from the current URL.
      	// Optionally, get query to pre fill the form.
      	const currentURL = new URL(window.location.href);
      	const urlParams = new URLSearchParams(currentURL.search);
      	const product = urlParams.get('emb_product');
      	// Update the sysId of the component property.
      	// Optionally, update the prefill fields property
      	const prefillConfig = {
      		product: product
      	};
      	setProperties(snEmbedxCaseForm,{
      		prefillFields: prefillConfig
      	});
      */
      
      	getEmbeddables(["sn-embedx-case-form"]);
      
      	const eventHandlers = {
      		'SN_EMBEDX_CASE_FORM#COMPONENT_ERROR' : (e) => {
      			// This event is dispatched when a property validation or internal error occurs.
      			var {errorMessage, errorType} = e.detail.payload;
      			console.log(errorMessage, errorType);
      		},
      		'SN_EMBEDX_CASE_FORM#COMPONENT_READY' : (e) => {
      			// This event is dispatched when a component is ready and usable.
      		},
      		'SN_EMBEDX_CASE_FORM#BUTTON_CLICKED' : (e) => {
      			// This event is dispatched if any button is clicked on the confirmation message.
      			var {table, record_sys_id, button_variant} = e.detail.payload;
      			var primaryURL =  '/caseview'; // Replace with the URL of the case view page
      			var secondaryURL = '/browse'; // Replace with the URL of the secondary page
      
      			if(button_variant == 'primary') {
      				// Construct the URL for the Case View component with URL parameters
      				const caseViewURL = primaryURL+'?emb_table='+table+'&emb_recordid='+record_sys_id;
      				open(caseViewURL,'_self'); // Open case record when primary button is clicked
      			}
      			else {
      				// Open the Case View component in the same tab
      				open(secondaryURL,'_self');
      			}
      		},
      		'SN_EMBEDX_CASE_FORM#RECORD_CREATION_SUCCEEDED' : (e) => {
      			// This event is dispatched if the record was successfully created.
      			var {table, record_sys_id} = e.detail.payload;
      			console.log(table, record_sys_id);
      		},
      		'SN_EMBEDX_CASE_FORM#RECORD_CREATION_FAILED' : (e) => {
      			// This event is dispatched if the record creation has failed.
      		},
      		'SN_EMBEDX_CASE_FORM#COMPONENT_NOTIFICATION_SENT' : (e) => {
      			// This event is dispatched when the component provides a notification for the end user.
      			var {items} = e.detail.payload;
      			console.log(items);
      		}
      	};
      
      	setEvents(snEmbedxCaseForm, eventHandlers);
      </script>
      

    결과

    전역 및 구성요소 코드를 외부 공급업체 관리자와 공유하여 케이스 생성 구성요소 인스턴스를 외부 공급업체 웹 사이트에 포함할 준비가 되었습니다.

    다음에 수행할 작업

    외부 공급업체 웹 사이트에 케이스 생성 구성요소 인스턴스 포함