Loading
Upcoming Mandatory Changes to Public Key Infrastructure (PKI)Read More
Agentforce Field Service and Operations
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Setting the Service Document Template Field

          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

          Available in: Lightning Experience.
          The Field Service core features, managed package, and mobile app are available in Enterprise, Unlimited, and Developer Editions.

          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=.

          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:
            // 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.
           
          Loading
          Salesforce Help | Article