---
sourceDocument: 브라질 직원 서비스 관리
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/employee-service-management

 Release :

    - brazil

ft:locale :

    - ko-KR

ft:publication_title :

    - 브라질 직원 서비스 관리

ft:clusterId :

    - emplsm

bundleId :

    - emplsm

workflow :

    - Employee


---

# 문서 템플릿 스크립트

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

릴리스 버전: Brazil  
업데이트 날짜 2026년 09월 10일  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 6분  
문서 템플릿 스크립트를 사용하면 HTML 템플릿 본문의 텍스트를 동적으로 변경할 수 있습니다. 문서 템플릿 스크립트를 사용하면 HR 데이터 표시와 같은 간단한 작업을 수행하거나 고급 데이터베이스 쿼리를 만드는 것과 같은 복잡한 작업을 수행할 수 있습니다.
`${template_script:script name}` 포함된 스크립트 태그를 HTML 템플릿 본문에 추가하여 스크립트 이름을 생성한 스크립트의 이름으로 바꿀 수 있습니다. 이렇게 하면 여러 문서 템플릿에서 동일한 스크립트를 쉽게 사용할 수 있습니다. 다음으로 이동하여 스크립트를 생성할 수 있습니다.문서 템플릿문서 템플릿 스크립트.  
주:  
HTML 템플릿에서 삭제 옵션을 활성화하면 HTML 스크립트의 출력이 자동으로 삭제됩니다. 자세한 내용은 에서 필드 정리를[HTML 문서 템플릿 구성](https://servicenow-prod.fluidtopics.net/FRLCOPmeVZqR8ES9GEKjKQ "고유한 회사 로고와 대상 기준을 사용하여 문서 템플릿을 만들거나 수정합니다.")참조하십시오.

## 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}

## 문서 템플릿 스크립트가 HTML 템플릿의 텍스트를 번역하는 방법의 예 {#document-template-scripts__section_kxn_35t_yyb}

다음은 직원 프로파일 문서의 비상 연락처 목록을 채우는 employee_emergency_contacts 스크립트입니다.

이 스크립트의 `docTemplate`은 문서 템플릿에서 선택한 언어 및 날짜 형식을 식별하는 데 도움이 되는 문서 템플릿 기록을 참조합니다. `getDisplayValueLang`은 동적 토큰의 언어를 문서 템플릿의 템플릿 언어 필드에 설정된 표시 언어로 변경하는 데 도움이 되는 API입니다. `getByFormat`은 문서 템플릿의 템플릿 날짜 형식 필드에 설정된 형식으로 날짜를 표시하는 데 도움이 되는 API입니다.  

    (function runTemplateScript(target /*GlideRecord for target task*/, docTemplate /*GlideRecord for doc template*/) {

        //Add your code here to return the dynamic content for template
        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 templateLang = docTemplate.getValue('language');
        var templateDateFormat = docTemplate.getValue('template_date_format');
        var hrTaskGr = new GlideRecord('sn_hr_core_contact');
        hrTaskGr.addQuery('user', target.getValue('subject_person'));
        hrTaskGr.query();
        while(hrTaskGr.next()) {
            var dob = hrTaskGr.getDisplayValue('date_of_birth');
            var grDOB = new GlideDateTime(dob);
            html = html + '<tr>';
            html = html + getDataCell(hrTaskGr.getDisplayValue('name'));
            html = html + getDataCell(hrTaskGr.getDisplayValue('mobile_phone'));
            html = html + getDataCell(hrTaskGr.getElement('relation_to_employee').getDisplayValueLang(templateLang));
            html = html + getDataCell(hrTaskGr.getElement('priority').getDisplayValueLang(templateLang));
            html = html + getDataCell(grDOB.getLocalDate().getByFormat(templateDateFormat)
            );
            html = html + '</tr>';
        }
        
        if(!gs.nil(html))
            html = '<h4>Emergency Contact Information</h4><table width="500px;"><tr>' + getHeaderCell('Name') + getHeaderCell('Mobile phone') + getHeaderCell('Relationship') + getHeaderCell('Priority') + getHeaderCell('Date of birth') + html + '</table>';
        
        return html;

    })(target, docTemplate);

다음은 HTML 문서 템플릿에서 동적 토큰이 변환되는 방법의 예입니다.

1. HTML 템플릿을 구성하는 동안 템플릿 언어는 독일어로 선택되고 날짜 형식은 dd/MM/yyyy로 설정됩니다.
2. HTML 문서 템플릿은 HR 케이스에서 참조됩니다.
3. 에이전트가 문서를 미리 보거나, 첨부 파일을 생성하거나, 참가자를 위한 문서 작업을 시작하면 우선순위 및 관계 필드가 독일어로 번역되고 날짜가 dd/MM/yyyy 형식으로 표시됩니다.

{#document-template-scripts__ol_h5w_xmk_zyb}

