---
sourceDocument: 요코하마 직원 서비스 관리
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/yokohama/employee-service-management

 Release :

    - yokohama

ft:locale :

    - ko-KR

ft:publication_title :

    - 요코하마 직원 서비스 관리

ft:clusterId :

    - emplsm

bundleId :

    - emplsm

workflow :

    - Employee


---

# 문서 템플릿 스크립트

# 문서 템플릿 스크립트 {#ariaid-title1}

* 릴리스 버전: Yokohama
* 
* 업데이트 날짜 2025년 01월 30일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 2분

문서 템플릿 스크립트를 사용하면 HTML 템플릿 본문의 텍스트를 동적으로 변경할 수 있습니다. 문서 템플릿 스크립트를 사용하면 HR 데이터 표시와 같은 간단한 작업을 수행하거나 고급 데이터베이스 쿼리를 만드는 것과 같은 복잡한 작업을 수행할 수 있습니다.
`${template_script:script name}` 포함된 스크립트 태그를 HTML 템플릿 본문에 추가하여 스크립트 이름을 생성한 스크립트의 이름으로 바꿀 수 있습니다. 이렇게 하면 여러 문서 템플릿에서 동일한 스크립트를 쉽게 사용할 수 있습니다. 다음으로 이동하여 스크립트를 생성할 수 있습니다.문서 템플릿문서 템플릿 스크립트.

## HTML 템플릿에서 문서 템플릿 스크립트를 만들고 사용하는 방법의 예 {#document-template-scripts__section_ffw_ftq_klb}

1. employee_emergency_contacts 스크립트는 직원 프로필 문서의 비상 연락처 목록을 채웁니다.  

       (function runTemplateScript(target /*GlideRecord for target task*/ ) {
       	var getHeaderCell = function(label) {
       		return '<th style="border: 1px solid #dddddd; text-align: left; padding: 8px;">' + label + '</th>';
       	};	
       	var getDataCell = function(value) {
       		return '<td style="border: 1px solid #dddddd; text-align: left; padding: 8px;">' + value + '</td>';
       	};
       	
       	var html = '';
       	var hrTaskGr = new GlideRecord('sn_hr_core_contact');
       	hrTaskGr.addQuery('user', target.getValue('subject_person'));
       	hrTaskGr.query();
       	while(hrTaskGr.next()) {
       		html = html + '<tr>';
       		html = html + getDataCell(hrTaskGr.getDisplayValue('name'));
       		html = html + getDataCell(hrTaskGr.getDisplayValue('mobile_phone'));
       		html = html + getDataCell(hrTaskGr.getDisplayValue('relation_to_employee'));
       		html = html + '</tr>';
       	}
       	
       	if(!gs.nil(html))
       		html = '<h4>Emergency Contact Information</h4><table width="500px;"><tr>' + getHeaderCell('Name') + getHeaderCell('Mobile phone') + getHeaderCell('Relationship') + html + '</table>';
       	
       	return html;
       })(target);

2. employee_emergency_contacts 스크립트는 직원 프로파일 HTML 문서 템플릿의 본문에 $ {template_script:employee_emergency_contacts} 를 입력하여 HTML 문서 템플릿에서 호출됩니다.

3. 케이스에서 직원 프로파일 HTML 문서 템플릿이 선택되고 다음과 같이 비상 연락처 목록과 함께 문서 템플릿이 생성됩니다.

{#document-template-scripts__ol_a33_kl5_glb}

