---
sourceDocument: Xanadu 従業員サービス管理 (ESM)
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/employee-service-management

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu 従業員サービス管理 (ESM)

ft:clusterId :

    - emplsm

bundleId :

    - emplsm

workflow :

    - Employee


---

# ドキュメントテンプレートの使用：一般的なユースケース

# ドキュメントテンプレートの使用：一般的なユースケース {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：2分

HR サービスデリバリ (HRSD) の外部でドキュメントテンプレートを使用する方法を理解します。

## 始める前に

必要なロール：admin

## 手順

1. 特定のテーブル (インシデントテーブルなど) のドキュメントテンプレートを定義します。
2. ドキュメントテンプレートに参加者が設定されている場合は、次の API を使用して参加者のドキュメントタスクを開始します。  

       /**
       * Description: Method to prefill document with mapped values and attach it to record table.
       * @param {GlideRecord} taskGr (GlideRecord of task table)
       * @param {String} htmlBody html body of document (Optional, if not passed then it will be generated from template for html template)
       * @param {SysId} docTemplateId (sysId of document template)
       * @param {String} generatedPdfName name of generated pdf (Optional, if not passed then it will be taken from template name)
       * @param {String} documentId (word template attachment sysId) (Only for word templates)
       * @return {boolean} true/false
       */
       new sn_doc.GenerateDocumentAPI().initiateDocumentTasks(taskGr, htmlBody, docTemplateId, generatedPdfName, documentId)

3. ドキュメントテンプレートから PDF ドキュメントを生成するには、次の API を使用します。  

       /**
       * Description: Method to generate a PDF from a document template.
       * @param {GlideRecord} recordId (GlideRecord of task table)
       * @param {documentTemplateId} docTemplateId (sysId of document template)
       * @param {String} pdfName name of generated pdf (Optional, if not passed then it will be taken from template name)
       * @return {sysId} (sysId of the attachment)
       */
       new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName)

4. レコードに関連付けられているドキュメントタスクを表示するには、以下を実行します。  
   1. レコード (インシデントレコードなど) を開きます。
   2. 関連リストを構成します。

      スラッシュバケットが開きます。\[ドキュメントタスク -\> 親\] を追加して \[保存\] します。
      レコードに関連付けられたドキュメントタスクが、\[ドキュメントタスク\] 関連リストに表示されます。

{#doc-temp-gen__ol_gz5_sjz_zyb}

