PostTemplate defines the information included in approval request posts displayed in Chatter feeds for Approvals in Chatter. It is object-specific presentation configuration used by approval processes, not the approval process itself.
A template can be selected explicitly by an approval process or used as the default for its object. Its display label is not its unique metadata identity, and its default setting controls fallback selection, not whether an approval process can use it.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
Inherited from Metadata. Identifies the component using <objectName>.<componentName>, such as Lead.leadtemplate. The object prefix identifies its object context. |
default |
Required boolean: true or false. When true, approval processes for the same object use this template if they do not specify one explicitly. |
fields |
Required repeated list of field API names. Includes up to four fields in approval request posts. Selected custom fields reference CustomField metadata. |
label |
Required, non-unique display name. It does not replace the component's unique metadata name. |
description |
Optional description of the template, separate from its display label and component identity. |
Behavior and Constraints
Salesforce selects the post template in this order:
- If the
ApprovalProcessspecifiespostTemplate, it uses that template. - Otherwise, it uses the template for the same object whose
defaultvalue istrue. - If the object has no default post template, a process without an explicit selection uses the system default post template.
A template with default=false remains available for explicit selection by an approval process. The required boolean is not an enablement or activation flag.
Changing the object default can affect processes that have no explicit postTemplate reference. A dependency check that looks only for incoming references can therefore miss affected processes. Processes with explicit template selections do not switch merely because the object default changes.
The fields list can contain no more than four field API names. Each selected field is represented by a separate fields element.
If the approval object is the detail object in a master-detail relationship, Owner is unavailable for approval post templates. This is a restriction caused by the object's relationship configuration, not simply a missing field reference.
Deployment and Retrieval
Metadata API files use the .postTemplate suffix and reside in the postTemplates folder. For example, the component Lead.leadtemplate corresponds to postTemplates/Lead.leadtemplate.postTemplate.
In package.xml, use PostTemplate as the type name and the full component identity, such as Lead.leadtemplate, as the member name. Do not substitute the display label. This type also supports the * wildcard in the manifest.
When preparing a deployment, account for both kinds of dependency: custom fields selected in fields, and approval processes that select the template through postTemplate. For a change to the object default, also review processes for that object that omit postTemplate; their template selection depends on the fallback rules rather than an explicit reference.
Preserve namespace prefixes and the full component name when identifying the template or resolving its object association. A shared label does not make two templates the same component.
Relationships
Explicit relationships connect a post template to its selected custom fields and to approval processes that select it. Processes using the object default are implicit consumers and may not appear in an incoming-reference list.
References
-
CustomField:fields, when a selected field is custom.
Referenced By
-
ApprovalProcess:postTemplate.
Name-based association: CustomObject is associated through the text before the first period in the component name. In Lead.leadtemplate, Lead identifies the object metadata context. That context can be a standard or custom object. This association is separate from XML element references; by itself, it establishes neither containment nor a required deployment sequence, and it is not authorization to delete either component.
Reported Issues
-
Direct Apex SOQL access was reported unavailable for
PostTemplate. A 2021 community inventory listed it among types that were not exposed in the ApexSchemanamespace and could not be queried from Apex. This is a reported access limitation, not a deployment error. See the Apex queryability discussion.
Common Questions
Can an approval process use a PostTemplate with default set to false?
Yes. An explicit ApprovalProcess.postTemplate selection takes precedence. Setting default=false only prevents the template from serving as the object's fallback selection.
Why did changing the default post template affect a process with no reference to it?
A process without an explicit postTemplate uses its object's default template. Those implicit consumers can be missed by checks that only inspect incoming references.
How many fields can an approval post template include?
Up to four fields, specified with repeated fields elements. If the approval object is the detail object in a master-detail relationship, Owner is unavailable.
How do I retrieve PostTemplate metadata with package.xml?
Use the type name PostTemplate and a member such as Lead.leadtemplate, or use *. Metadata API files are stored in postTemplates with the .postTemplate suffix.
Should I identify a post template by its label or its full name?
Use its full component identity, such as Lead.leadtemplate. The required label is a non-unique display name and cannot reliably distinguish templates.