Help Center Template Editor Create a Document Template

How to Create a Document Template in Salesforce with Dochly

Updated June 2026 10 min read Template Editor
A document template is the foundation of every automated document workflow in Dochly. Before you can generate proposals, contracts, invoices, or onboarding packets with a single click, you need a template that defines the structure, content, and data fields of that document. This guide walks you through everything you need to create your first document template in Salesforce — from opening the editor to inserting merge fields, applying formatting, and publishing for use across your org.

What is a document template in Dochly?

A document template in Dochly is a reusable document blueprint stored natively inside Salesforce. It defines the layout, content, and data fields of a document — and when triggered, it pulls live data from a Salesforce record to generate a complete, accurate document instantly.

Templates are built inside the Dochly Template Editor, which runs entirely within Salesforce. There is no need to export to Word, upload to an external tool, or manage files outside your org.

Stored as a Salesforce object

Not an external file. Templates live inside your Salesforce org and are subject to your org's security and retention policies.

Linked to a primary object

Each template is tied to an Opportunity, Account, Contract, Case, or any custom object — determining which fields are available.

Merge fields pull live data

Placeholders in the template are replaced with actual Salesforce record values at the moment of generation. See adding merge fields.

Conditional logic supported

Sections show or hide based on field values — one template handles multiple document variations automatically.

Dynamic tables & repeating rows

Line item tables expand automatically to match related records — products, services, tasks, whatever your document needs.

Triggerable by automation

Generate documents via button click, Salesforce Flow, approval process, or scheduled job — no manual work required.


Document types you can build

Dochly templates support any document type your business generates. The template creation process is the same for all types — the difference is which Salesforce object you select as the primary record and which fields you map as merge fields.

Sales documents

Proposals, quotes, order confirmations, pricing sheets — typically based on the Opportunity object. See creating a proposal template.

Legal documents

Contracts, NDAs, master service agreements, amendments. See the dedicated guide for creating a contract template.

Financial documents

Invoices, statements, renewal notices, payment receipts. See the guide for creating an invoice template.

HR documents

Offer letters, employment agreements, policy acknowledgments — typically based on a custom HR or candidate object.

Operational documents

Statements of work, onboarding packets, project summaries — often pulling from multiple related Salesforce objects.

Compliance documents

Case summaries, audit reports, regulatory filings — typically based on the Case object with required regulatory fields.


Before you start: prerequisites

Before creating your first template, confirm the following. Skipping any of these steps is the most common cause of merge field errors and blank outputs in production.

  • 1
    Dochly is installed and connected — Dochly must be installed from Salesforce AppExchange and connected to your Salesforce org before you can access the template editor.
  • 2
    You have the right Salesforce permissions — you need access to the Salesforce object and fields you want to use. Field-level security applies — if a field is restricted for your profile, it won't be available as a merge field.
  • 3
    Your Salesforce data is clean — templates pull data from Salesforce records. Fields that are empty, inconsistently formatted, or missing will produce blank or incorrect merge field outputs. Audit your fields before building.
  • 4
    You know which object to use — every template is linked to a primary Salesforce object. For most sales documents, this is the Opportunity. Decide this before you start — it determines which fields are available in the editor.
Dochly
Available on Salesforce AppExchange Dochly by UTECH HUB — Install Free

100% native Salesforce document generation & e-signature platform


Step-by-step: creating your first document template

1

Navigate to the Template Editor

From Salesforce, open the Dochly app. In the navigation menu, go to Templates. Click New Template to open the template editor.

The template editor opens inside Salesforce — no new browser tabs, no external platforms, no login to a separate tool. Everything runs natively within your org.

2

Name your template and select the primary object

Give your template a clear, descriptive name using a consistent format — for example: "Sales Proposal — Enterprise", "Invoice — Standard", "Offer Letter — Full-Time". See the guide to managing multiple templates for naming conventions.

Next, select the Primary Salesforce Object. This determines which fields are directly available as merge fields:

  • Opportunity — most sales documents (proposals, contracts, quotes)
  • Account — account-level agreements and correspondence
  • Contract — formal contract documents linked to the Contract object
  • Case — case summaries and compliance records
  • Custom objects — any custom object your org has created
3

Choose your document format

Select the output format for your template. For most automated workflows — especially those connected to e-signature — PDF is the recommended format.

PDF

Most common for final documents sent to customers. Fixed layout, professional appearance, ideal for e-signature workflows.

DOCX

Useful when the recipient needs to edit the document further. Generates a Word-compatible file from your Salesforce data.

4

Set up the document structure

Build the core structural elements using the template editor's formatting toolbar. Most business documents follow this structure:

  • Header: Company logo, company name, document title, date
  • Recipient section: Customer name, contact details, billing address
  • Body section: Main document content — varies by document type
  • Footer: Page numbers, confidentiality notice, company contact info

For brand-consistent formatting across all templates, see Build a branded document template in Dochly.

5

Insert merge fields

Merge fields are placeholders that get replaced with live Salesforce data when the document is generated. Place your cursor where the data should appear, open the merge field picker, and click to insert.

Common merge fields for most document types:

{{Name}} — opportunity name
{{Account.Name}} — account/company name
{{Contact.FirstName}} — contact first name
{{Contact.LastName}} — contact last name
{{Contact.Email}} — contact email address
{{Amount}} — deal amount
{{CloseDate}} — close / effective date
{{Owner.Name}} — account owner name
{{TODAY}} — today's date (auto-populated)

Fields from related objects are accessed via relationship paths:

{{Account.BillingStreet}} — billing street from Account
{{Account.BillingCity}} — billing city from Account
{{Owner.Email}} — owner email via relationship

Full merge field guide: Add Salesforce merge fields to a document template

6

Add dynamic tables for line items

For documents that include a list of products, services, or fees that varies by record, use a dynamic table with repeating rows. The table automatically expands to accommodate however many related records exist — no manual counting or blank rows:

Product Name | Qty | Unit Price | Total
{{LineItem.Name}} | {{LineItem.Quantity}} | {{LineItem.UnitPrice}} | {{LineItem.TotalPrice}}

Subtotal: {{Amount}}
7

Apply conditional logic (optional but recommended)

Conditional logic lets sections appear or disappear based on Salesforce field values. This is what allows one master template to handle multiple document variations without maintaining separate templates for each scenario:

{IF Type = "Enterprise"}
[Enterprise-specific terms and SLA content]
{END IF}

{IF Account.BillingCountry = "United Kingdom"}
[UK-specific legal language and jurisdiction]
{END IF}

{IF Payment_Terms__c = "Installments"}
[Installment schedule and payment terms]
{END IF}

Conditional logic can wrap any content — paragraphs, tables, images, or entire sections. It also controls which signature blocks appear based on document type or deal stage.

8

Add a signature block (if required)

For documents that need to be signed, add a signature block at the end of the template. Position fields for each required signatory — name, title, and date.

Authorized by: ________________ Date: ________________
{{Contact.FirstName}} {{Contact.LastName}}

Approved by: ________________ Date: ________________
[Your Company Representative]

When connected to Dochly's native e-signature, these blocks become interactive digital signature fields — signers click to sign without any external platform or account creation.

9

Preview and test your template

Before saving and publishing, generate a test document from a real Salesforce record. Click Preview in the editor toolbar, select a record with complete data, and review the output carefully.

What to check in preview:

  • All merge fields populate with the correct data — no "null" or blank values
  • Dynamic tables expand correctly for records with multiple line items
  • Conditional sections appear and disappear as expected
  • Formatting — fonts, spacing, page breaks — looks correct throughout

Test with edge cases: a record with zero line items, a record with missing optional fields, records that trigger each conditional branch. If something looks wrong, see Template Editor troubleshooting — common errors and fixes.

10

Save and publish the template

Once your preview looks correct, save the template and set its status to Active. Active templates are available for use across your org — by button click, Flow automation, approval process, or scheduled job.

Draft

Template is being built — not available for document generation yet.

Active

Template is live and available for generation across your org.

Inactive

Template is retired but preserved — available for audit and reference.

To update an active template later: Edit and update an existing document template in Dochly


Connecting your template to generation triggers

A published template needs a trigger to generate documents. Connect it to one of these four options — or combine them for different use cases within the same org:

Button click

Add a "Generate Document" button to the record page layout. Users click it to select a template and generate on demand — useful for documents that need human review before sending.

Salesforce Flow

Trigger document generation automatically based on a record event — stage change, field update, approval completion, or date condition. Recommended for fully automated workflows.

Approval process

Set document generation as the final action of an approval process — the document is generated and sent automatically when the last approval is granted.

Scheduled job

Use a scheduled Flow to run batch document generation on a regular schedule — monthly invoices, weekly reports, renewal notices. Set it once, it runs automatically.


Naming and organization best practices

As your template library grows, keeping it organized becomes important. Follow these conventions from day one — they save significant time when managing a large template library. See managing multiple document templates in Dochly for the full guide.

  • Use a consistent naming format: [Document Type] — [Variant] (e.g. "Proposal — Enterprise", "Invoice — Standard", "Offer Letter — Part-Time")
  • Include the primary object in template names when templates exist for multiple objects (e.g. "Account Agreement" vs "Opportunity Contract")
  • Use Draft status while building — only set to Active when the template is fully tested and ready for production use
  • Never overwrite a published template — create a new version instead. See editing and updating existing templates
  • Archive rather than delete — set old templates to Inactive rather than deleting them, in case they're needed for audit or reference
  • Duplicate before modifying — when building a similar template, duplicate an existing one and adjust rather than starting from scratch

Frequently asked questions

There is no hard limit on the number of templates. You can create as many templates as your business requires across any number of Salesforce objects.
Yes. You can duplicate any existing template and use it as the foundation for a new one. This is the recommended approach when building multiple similar document types — it's significantly faster than starting from scratch each time.
Template access is controlled by Salesforce profiles and permission sets. You can grant template editing access to specific users or roles without giving them full admin access.
If a merge field has no value on the record, it generates as a blank space by default. You can configure fallback values or use conditional logic to handle empty fields gracefully and prevent blank sections in your output. See the troubleshooting guide for common merge field errors.
Each template is linked to a single primary object. For documents that span multiple object types, create separate templates for each and use the same content structure with different merge field paths.
Generated documents are stored as Salesforce Files attached to the record that triggered generation — immediately accessible to anyone with record access, without leaving Salesforce.

You're ready to build your first document template. Start by opening the template editor, selecting the Opportunity as your primary object, and inserting your first merge fields. Once your template is published, connect it to a Flow trigger or button click to start generating documents automatically. Next steps: Add Salesforce merge fields · Build a branded template · Troubleshooting guide

Dochly
Salesforce AppExchange — UTECH HUB Install Dochly on AppExchange

Rated 5 stars · Native Salesforce app · Free to install