Newer Version Available

This content describes an older version of this product. View Latest

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

Field Name Description
contextDefinitionName
Field Type
string
Description
Context service definition that describes the relationship between node structures within a context. Available in API version 65.0 and later.
contextMappingName
Field 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.
customClassName
Field Type
string
Description
Custom class to process document template operations and transformations.
defaultFontStyle
Field Type
string
Description
Default font styling applied to the document template content.
documentConversionResourceName
Field Type
string
Description
Conversion resource reference used for transforming document content between formats.
documentGenerationMechanism
Field 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
  • ServerSide

The default value is ClientSide.

extractOmniDataTransformName
Field Type
string
Description
Data extraction transform name for OmniStudio integration, enabling extraction of data from various sources for template processing.
fileExtension
Field Type
string
Description
Output file format extension for documents generated from this template.
hasBatchableSection
Field Type
boolean
Description
Indicates whether the template supports batch processing of sections (true) or not (false).

The default value is false.

isActive
Field Type
boolean
Description
Indicates whether the template is active and available for document generation (true) or not (false).

The default value is false.

isSectionProcessed
Field Type
boolean
Description
Indicates whether sections are processed in the template (true) or not (false).

The default value is false.

lastEmbeddedTmplSectionKey
Field Type
string
Description
Last processed section key for embedded template processing, used for tracking template section processing state.
mapperOmniDataTransformName
Field 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
Field Type
string
Description
Display label for the template that appears in the user interface.
name
Field Type
string
Description
Internal name used to identify the template within the system.
namespace
Field Type
string
Description
Package namespace for the template used in managed package deployments.
sectionHeaderFontStyle
Field Type
string
Description
Header font styling applied to section headers within the document template.
sectionHeaderFontStyleValue
Field Type
string
Description
Header font values and properties for section header styling configuration.
shouldDisplayUnmappedToken
Field Type
boolean
Description
Indicates whether unmapped tokens must be displayed in the generated document (true) or not (false).

The default value is false.

shouldExtractEmbeddedTmplToken
Field Type
boolean
Description
Indicates whether embedded template tokens must be extracted during processing (true) or not (false).

The default value is false.

status
Field 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
  • Draft
targetTokenItemObject
Field 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
  • QUOTE_LINE_ITEM
targetTokenObject
Field 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
  • QUOTE
tokenList
Field Type
string
Description
List of available tokens that can be used within the template for dynamic content generation.
tokenMappingMethodType
Field 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
  • OmniDataTransform

The default value is ContextService.

tokenMappingType
Field 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
Field 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
Field Type
string
Description
Unique ID of the template, ensuring template uniqueness across the organization.
usageType
Field 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
  • Revenue_Lifecycle_Management
versionNumber
Field Type
string
Description
Template version number to track template revisions and changes over time.
xmlRelationshipMetadata
Field 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>65.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.