How to Create Document Templates in Salesforce: Complete Guide (2026)
Salesforce document templates are the pre-built files that your document generation tool uses to produce finished documents from CRM data. Every automated contract, invoice, NDA, and proposal your team generates starts with one of these templates. The template defines what the document looks like — the layout, fonts, branding, section headings, and text — while merge fields mark the spots where live Salesforce data gets inserted at generation time.
Getting your Salesforce document templates right is the foundation of everything else in document generation. A well-built template generates consistent, professional documents for hundreds of records without manual adjustment. A poorly built one produces documents that break on certain records or require editing after every generation.
This guide covers exactly how to create Salesforce document templates that work reliably at scale. For background on how the generation process works, see our guide on how to generate documents in Salesforce step by step.
What is a Salesforce document template?
A Salesforce document template is a structured file that combines fixed content with dynamic merge fields that reference Salesforce record data. When a document is generated from a Salesforce record, the template engine replaces every merge field with the live value from that record.
The same Salesforce document template can be used to generate thousands of documents. Each generated document is unique because the merge fields pull different values from different records, but the structure, formatting, and fixed content remain identical across every output.
Salesforce document templates are distinct from standard Salesforce email templates. Email templates are for sending emails from records. Document templates are for generating PDFs, Word files, and other document formats. The merge field concept is the same; the format and generation process are different.
Choosing a template format: Word vs. native editor
Most Salesforce document generation tools support two template formats: Word document templates and native template editors built into the tool. The right choice depends on document complexity and your team’s technical comfort.
Word-based Salesforce document templates are built in Microsoft Word with merge fields inserted as plain text. Word is well-suited to documents with complex formatting, branded headers and footers, multi-column layouts, and rich text styling. For branded enterprise documents, Word gives the most precise control over the final PDF output.
Native Salesforce document templates are built inside the document generation tool using a visual, no-code editor where you select fields from a list, configure repeat blocks, and set conditional logic without editing raw syntax. Native editors are faster for simple documents and easier for non-technical team members.
Read more: Salesforce Merge Fields: A Beginner’s Guide With Examples (2026)
How to create a Salesforce document template in Word
Building Salesforce document templates in Word follows seven steps: start with the finished document, build the static structure, replace variable data with merge fields, add dynamic tables, add conditional sections, format dates and currency, and test against multiple records.
A document template built in Word uses merge field syntax to reference Salesforce field API names. The template engine replaces each placeholder with live data at generation time.
Start with the finished document as your model
Get a copy of the document as it is currently produced manually. This becomes your blueprint. The template should produce output that is identical in structure and format to the manual version, with merge fields replacing the data that varies between records.
Build the static structure
In Word, build the complete document structure with all fixed content in place: letterhead, section headings, standard terms text, signature blocks, footer content, and page numbers. Do not add merge fields yet. Get the document looking exactly right as a static file first.
Replace variable data with merge fields
Go through the document and identify every piece of data that will change between records: client name, deal value, start date, product details, signatory name. Replace each one with the corresponding merge field in your Salesforce document template using your generation tool’s syntax.
Add dynamic tables for line items
If the document includes a product table, pricing schedule, or any other section where the number of rows varies between records, replace that section with a repeat block. Place the repeat markers around the row that should repeat and add merge fields for each column.
Add conditional sections
Wrap any section that should only appear for certain records in a conditional block: a HIPAA clause for healthcare clients, enterprise service terms for large-deal opportunities, a relocation clause for out-of-city candidates.
Format dates and currency values
Apply format modifiers to date and currency fields so they appear in the correct readable format. A raw date field produces an ISO string like 2026-07-15. A formatted field produces July 15, 2026.
Test against multiple records
Generate test documents from at least four record types: a complete record, a record with optional fields blank, a record with multiple related child records, and a record with zero child records. Fix any issues, then re-test before marking the template production-ready.
A repeat block iterates over related child records to generate a dynamic table. Three products produce three rows. Twelve produce twelve. The template does not change.
Using a native template editor for Salesforce document templates
Native template editors in document generation tools provide a visual, no-code interface for building Salesforce document templates without writing merge field syntax by hand. The editor displays a list of available fields from the connected Salesforce object and its related objects. You click to insert a field rather than typing the merge field token.
The key advantages of a native editor:
- No syntax errors — fields are selected from a list rather than typed, eliminating API name mismatches that cause blank fields
- Real-time preview — see how the template looks with sample data before generating a real document
- Conditions through UI — select field, operator, and value through a form rather than inserting raw if/else markers
- Shared template management — templates stored as Salesforce records benefit from Salesforce’s version control and sharing rules automatically
Dochly supports both Word-based templates and a native visual editor inside Salesforce. For rapid creation without technical knowledge, the native editor is the faster path. For branded documents with precise layout requirements, Word templates give the most control.
Adding branding to Salesforce document templates
Branded Salesforce document templates maintain consistent visual identity across every generated document. For businesses sending contracts, proposals, and invoices to clients, visual consistency is a professionalism signal.
Logo placement. In a Word template, insert the logo as an image in the header or at the top of the first page. Anchor the image to the page rather than to the text so it does not shift when merge fields on adjacent lines are populated with different-length values.
Colour and font. Set the document’s base font to your brand font. Apply your brand colour to headings. Use Styles in Word rather than direct formatting so that font and colour settings apply consistently across the entire document.
Header and footer. Add a page header with your company logo and document title. Add a footer with page numbers, company registration details, confidentiality notice, or document date. Use Word’s built-in header and footer functionality so these repeat consistently across all pages including pages generated dynamically by repeat blocks.
A branded template produces consistent, professional documents for every record — no manual formatting adjustment required after generation.
Managing multiple Salesforce document templates
Most Salesforce orgs need several Salesforce document templates: at least one contract, one invoice, one NDA, and one or more HR or onboarding documents. As the library grows, a few management practices keep it clean and maintainable.
Name templates clearly. Use a naming convention that includes the document type, the triggering object, and the version: Sales-Contract-Opportunity-v2, Invoice-Opportunity-v1, Offer-Letter-Contact-v3. Avoid generic names like Contract-Template or New-Doc.
Assign templates to specific user profiles. Not every template should be available to every user. Sales reps do not need HR templates. Finance users do not need sales proposals. Configure template access by profile or permission set.
Version control. When updating a live template, create a new version rather than editing the active one. This preserves a record of what was in use before the change, which matters for compliance reviews.
Retire old templates explicitly. Mark obsolete templates as inactive rather than deleting them. Deleted templates break any historical audit trail linking generated documents back to the template version they were produced from.
Do not delete active templates. Deleting a template that has generated documents breaks the audit trail. Always deactivate rather than delete, and only archive after confirming no active workflows depend on the template.
Connecting Salesforce document templates to objects and Flows
Once your Salesforce document templates are built, connecting each one to the correct Salesforce object and adding a trigger turns it into a working document generation workflow.
Object connection. In the template settings, select the primary Salesforce object. For a contract template, this is typically Opportunity or Contract. For an invoice, it is Opportunity or a custom billing object. For an NDA, it is Contact or Opportunity.
Output configuration. Set the output format (PDF or Word), the file naming convention using merge fields, and the storage destination. Native tools store documents generated from Salesforce document templates as Salesforce Files on the linked record automatically.
Page layout button. Add a generation button to the relevant page layout so users can trigger document generation directly from the record page.
Flow integration. For automated generation, connect the template to a Salesforce Flow. The Flow triggers based on a record event, calls the document generation action with the template ID and record ID as parameters, and continues to the next workflow step.
Frequently asked questions about Salesforce document templates
Well-built Salesforce document templates are the foundation of every automated document your team will generate. Getting them right the first time — with proper merge fields, dynamic tables, conditional sections, and branding — means consistent, professional output for every record without manual adjustment.
For the next step, see our guide on Salesforce merge fields with examples, or visit Dochly document generation to see the template editor in action inside a fully native Salesforce app.