DocumentTemplate

Represents the document template definitions that enable dynamic document generation from templates within Salesforce organizations.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

Parent Type 

This type extends the MetadataWithContent metadata type and inherits its content and fullName fields.

File Suffix and Directory Location 

DocumentTemplate components have the suffix .dt and are stored in the documentTemplates folder.

Version 

DocumentTemplate components are available in API version 59.0 and later.

Fields 

contextDefinitionName 

Type: string

Description: Context service definition that describes the relationship between node structures within a context. Available in API version 65.0 and later.

contextFilterName 

Type: string

Description: The name of the context filter that extracts records in the Context Service token mapping type. For example, filter Line Items with Total Price greater than 1000 and sort by Quantity in descending order. This is optional and applicable only for context token mapping. Available in API version 66.0 and later.

contextMappingName 

Type: string

Description: Context service mapping that defines the mapping of attributes and nodes to related objects. Available in API version 65.0 and later.

contextTransformationName 

Type: string

Description: Name of the context transformation used in the Context Service token mapping type. Applicable only for context token mapping. Available in API version 67.0 and later.

customClassName 

Type: string

Description: Custom class to process document template operations and transformations.

defaultFontStyle 

Type: string

Description: Default font styling applied to the document template content.

documentConversionResourceName 

Type: string

Description: Conversion resource reference used for transforming document content between formats.

documentGenerationMechanism 

Type: DocumentGenerationMechanism (enumeration of type string)

Description: Specifies how documents are generated from the template, defining the generation mechanism and processing approach.

Valid values are ClientSide or ServerSide. The default value is ClientSide.

extractOmniDataTransformName 

Type: string

Description: Data extraction transform name for OmniStudio integration, enabling extraction of data from various sources for template processing.

fileExtension 

Type: string

Description: Output file format extension for documents generated from this template.

hasBatchableSection 

Type: boolean

Description: Indicates whether the template supports batch processing of sections ( true) or not ( false). The default value is false.

isActive 

Type: boolean

Description: Indicates whether the template is active and available for document generation ( true) or not ( false). The default value is false.

isSectionProcessed 

Type: boolean

Description: Indicates whether sections are processed in the template ( true) or not ( false). The default value is false.

lastEmbeddedTmplSectionKey 

Type: string

Description: Last processed section key for embedded template processing, used for tracking template section processing state.

mapperOmniDataTransformName 

Type: string

Description: Data mapping transform name for OmniStudio integration, enabling mapping of data between different formats and structures. Available in API version 56.0 and later.

masterLabel 

Type: string

Description: Display label for the template that appears in the user interface.

name 

Type: string

Description: Internal name used to identify the template within the system.

namespace 

Type: string

Description: Package namespace for the template used in managed package deployments.

sectionHeaderFontStyle 

Type: string

Description: Header font styling applied to section headers within the document template.

sectionHeaderFontStyleValue 

Type: string

Description: Header font values and properties for section header styling configuration.

shouldDisplayUnmappedToken 

Type: boolean

Description: Indicates whether unmapped tokens must be displayed in the generated document ( true) or not ( false). The default value is false.

shouldExtractEmbeddedTmplToken 

Type: boolean

Description: Indicates whether embedded template tokens must be extracted during processing ( true) or not ( false). The default value is false.

status 

Type: DocumentTemplateStatus (enumeration of type string)

Description: Template status that indicates the current state and availability of the document template.

Valid values are Active, Archived, or Draft

targetTokenItemObject 

Type: TargetTokenItemObject (enumeration of type string)

Description: Target item object for token mapping, defining specific item-level token replacement rules and configurations.

Valid values are OPPORTUNITY_LINE_ITEM, ORDER_LINE_ITEM, or QUOTE_LINE_ITEM

targetTokenObject 

Type: TargetTokenObject (enumeration of type string)

Description: Target object for token mapping, defining the primary object used for token replacement and data binding.

Valid values are CONTRACT, OPPORTUNITY, ORDER, or QUOTE

tokenList 

Type: string

Description: List of available tokens that can be used within the template for dynamic content generation.

tokenMappingMethodType 

Type: TokenMappingMethodType (enumeration of type string)

Description: Token mapping method that defines the approach used for mapping tokens to data values.

Valid values are ContextService, CustomClass, or OmniDataTransform. The default value is ContextService.

tokenMappingType 

Type: TokenMappingType (enumeration of type string)

Description: Required.

Defines how tokens are mapped within the template, specifying the token mapping strategy and configuration.

Valid values are:

  • JSON
  • SalesforceObject

type 

Type: DocumentTemplateType (enumeration of type string)

Description: Required.

Type of document template, defining the category and intended use case of the template.

Valid values are:

  • HTMLArchive
  • Microsoft365Word
  • MicrosoftPowerpoint
  • MicrosoftWord
  • Web

uniqueName 

Type: string

Description: Unique ID of the template, ensuring template uniqueness across the organization.

usageType 

Type: DocumentTemplateUsageType (enumeration of type string)

Description: Defines how the template is used within the system, specifying the usage context and application scenarios.

Valid values are Contract_Lifecycle_Management or Revenue_Lifecycle_Management

versionNumber 

Type: string

Description: Template version number to track template revisions and changes over time.

xmlRelationshipMetadata 

Type: string

Description: Relationship metadata in XML format that defines connections and dependencies between template components.

Declarative Metadata Sample Definition 

This is an example of a DocumentTemplate component.

1<?xml version="1.0" encoding="UTF-8"?>
2<DocumentTemplate xmlns="http://soap.sforce.com/2006/04/metadata">
3    <customClassName></customClassName>
4    <defaultFontStyle>'Times New Roman', times, serif</defaultFontStyle>
5    <documentConversionResourceName></documentConversionResourceName>
6    <documentGenerationMechanism>ClientSide</documentGenerationMechanism>
7    <type>MicrosoftWord</type>
8    <usageType>Contract_Lifecycle_Management</usageType>
9    <extractOmniDataTransformName>extractorv1</extractOmniDataTransformName>
10    <mapperOmniDataTransformName>mapperv1</mapperOmniDataTransformName>
11    <fileExtension>docx</fileExtension>
12    <hasBatchableSection>false</hasBatchableSection>
13    <isActive>false</isActive>
14    <isSectionProcessed>false</isSectionProcessed>
15    <lastEmbeddedTmplSectionKey></lastEmbeddedTmplSectionKey>
16    <name>Sample</name>
17    <namespace></namespace>
18    <sectionHeaderFontStyle></sectionHeaderFontStyle>
19    <sectionHeaderFontStyleValue></sectionHeaderFontStyleValue>
20    <shouldDisplayUnmappedToken>false</shouldDisplayUnmappedToken>
21    <shouldExtractEmbeddedTmplToken>false</shouldExtractEmbeddedTmplToken>
22    <status>Draft</status>
23    <tokenList></tokenList>
24    <tokenMappingMethodType>OmniDataTransform</tokenMappingMethodType>
25    <tokenMappingType>JSON</tokenMappingType>
26    <targetTokenItemObject>OPPORTUNITY_LINE_ITEM</targetTokenItemObject>
27    <targetTokenObject>CONTRACT</targetTokenObject>
28    <uniqueName>Sample_1</uniqueName>
29    <versionNumber>1</versionNumber>
30    <xmlRelationshipMetadata></xmlRelationshipMetadata>
31    <masterLabel>Sample_1</masterLabel>
32</DocumentTemplate>

This is an example package.xml that references the previous definition.

1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3    <types>
4        <members>*</members>
5        <name>DocumentTemplate</name>
6    </types>
7    <version>68.0</version>
8</Package>

Wildcard Support in the Manifest File 

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.