---
sourceDocument: Xanadu Employee Service Management
sourceDocumentLink: https://www.servicenow.com/docs/r/xanadu/employee-service-management

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu Employee Service Management

ft:clusterId :

    - emplsm

bundleId :

    - emplsm

workflow :

    - Employee


---

# Document generation methods

# Document generation methods {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

A PDF document can be generated automatically, manually, or by using an API.

## Automatically {#generate-pdf-doctemp__section_ukb_lfp_xlb}

A PDF document is automatically added as an attachment to the case when:

1. The [configured template](https://www.servicenow.com/docs/qm97QBCftIXQIFMsqjpX4w "Upload an editable, fillable PDF template and customize the template as per your business needs.") is selected on the HR template of a service.
2. The Automatically Initiate Document tasks case option is selected on the HR service of a case.
3. The state of the HR case is changed to work in progress.
4. The document tasks of all the participants are complete.
{#generate-pdf-doctemp__ol_rhs_kdj_ylb}

## Manually {#generate-pdf-doctemp__section_okt_tfp_xlb}

A PDF document can be generated manually using the Generate option on
the Preview Document option on the case.

## API {#generate-pdf-doctemp__section_vv3_k2j_ylb}

The following API generates and attaches the document to the target record that is passed to the API.

    //recordId - Sys ID of the target record. This record must be from the table defined in the document template.
    //documentTemplateId - Sys ID of the document template to use for pdf generation.
    //pdfName - Name of the pdf generated
    new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);

Note:  
If your table is caller restricted, calling this API may generate RCA records from components in the Document Templates scope to your table. You must allow them.
**Related concepts**   

* [Document template categories](https://www.servicenow.com/docs/crOxO~oOjSxArWsIgA6C8w "Document template categories help you to categorize similar documents together. It makes finding the correct document template easier.")
* [Document Templates of type HTML](https://www.servicenow.com/docs/P1cDX102JoA6v7TmD4EVWw "An HTML document template uses variables to pre-fill information from tables into the document. You can create how the document looks by defining the header, footer, images, placement of footer, and the text within the template. Using the HTML document template, you can collect e-signatures from multiple participants and generate a PDF document online.")
* [Document Templates of type PDF (Advanced forms)](https://www.servicenow.com/docs/kSPS~KHdIyox0k6aacV4Nw "A PDF document template originates from a fillable PDF or a standard PDF with inline signatures. Using the PDF document template, you can collect details and e-signatures from multiple participants, review, and generate a filled PDF document.")
* [Document Templates configurations](https://www.servicenow.com/docs/APxoRcEx6LiUY0QX294HwA#doc-template-configs "Use Document Templates configurations to generate table of contents and page numbers on a PDF document that is generated from an HTML template.")
* [Document tasks generation](https://www.servicenow.com/docs/rCn_w2G0qC6zac9OGrhMYQ "Document tasks can be generated either automatically or manually. The tasks get generated in the order defined for the participants.")  
**Related tasks**   

* [Work on a document task](https://www.servicenow.com/docs/Tu2wCDuExp~y6dTSPxEkvw "Complete your document tasks from Employee Center.")

