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=.
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.
Did this article solve your issue?
Let us know so we can improve!
Loading
Salesforce Help | Article
Cookie Consent Manager
Cookie Consent Manager
General Information
Required Cookies
Functional Cookies
Advertising Cookies
General Information
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.