---
schema_version: "1"
id: e08a55a40a85e56abe0da8fc2cbfe81c0eb3bb4b89e97cd7e1ab552aa6a828bb
title: Setting the Service Document Template Field
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/service/264-0-0/fs_service_document_template_field.md
canonical_url: https://help.salesforce.com/s/articleView?id=service.fs_service_document_template_field.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 87f9baef966e0c6ca535e7ad3f5ec153f2c1915c4b2d8276f8f9e2d9553663fc
description: "You can find the standard field Service Document template in the three objects: Work Order, Work Order Line Item, and Service Appointment. This field points to the template ID, which sets the template for each service document. This topic covers how to find the template ID and how to populate the Service Document Template field."
products:
  - Field Service
release: "264"
---
# Setting the Service Document Template Field

You can find the standard field Service Document template in the three objects: Work Order, Work Order Line Item, and Service Appointment. This field points to the template ID, which sets the template for each service document. This topic covers how to find the template ID and how to populate the Service Document Template field.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience.</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">The Field Service core features, managed package, and mobile app are available in <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions.</td></tr></tbody></table>

## Find the Template ID

To get the template ID, open or create a template in Document Builder. You can find the template ID in the URL, after &id=.

![The template ID shows up in the URL after &id=.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-service-support_field_service-264-0-0-production-enus/3f7dceb9-dd70-454a-b49e-bbb4526a158d/support_field_service/images/fs_template_id_url.png)

If the field value is set, that template is used. If the field is empty, then the org default template is used. If the field is empty, you haven’t set a default, and you don’t have any templates, you receive an error message.

If you don’t set the Service Document Template from Work Order, Work Order Line Item, or Service Appointment, the document template can also be derived from one of the three corresponding Document Template fields on Work Type.

## Populate the Service Document Template Field

Populate the Service Document Template field using an Apex trigger, building a flow, or doing a combination of both.

- Apex Trigger: You can use an Apex trigger to perform custom actions, such as insertions, updates, or deletions, before or after events to records in Salesforce. The Apex trigger populates the Service Document field upon creating, reading, updating, or deleting any related records. Here’s a sample Apex trigger:
    
    ```java
    // Timing options:
    // before insert/update/delete
    // after insert/update/delete/undelete
    
    
    // Simple example trigger
    trigger PopulateServicedocument on WorkOrder(before insert) {
       for(WorkOrder wo : Trigger.New) {
           if (wo.Status == "value") {
               wo.ServiceDocumentTemplate = '0M0...';
           }
           // ...
       }
    }
    ```
- Flow Builder: Build flows that collect data and perform actions. You can build screen flows that launch after certain criteria are met, guiding users to set fields. Or, build flows that automatically run in the background, using Autolaunched Flow, with no trigger. Flow Builder also lets you run Apex code, including Apex triggers, so play around to see what works best for your document building needs.