How to Generate Documents in Salesforce: Best Complete Guide (2026)
Why document generation matters in Salesforce
Salesforce is the system of record for your customer relationships, and document generation closes the loop. It turns the data already in Salesforce into professional, accurate, ready-to-send documents without anyone rekeying a single field.
No manual data entry
Merge fields pull directly from Salesforce records — account names, deal amounts, dates, line items — with zero retyping.
No formatting errors
Templates enforce consistent branding and layout every time, no matter which user generates the document or from which record.
No version confusion
Documents are generated from the current state of the record — not a saved copy from last week that someone forgot to update.
No lost files
Completed documents are stored directly on the Salesforce record that generated them — instantly accessible, always findable.
No compliance gaps
Every document is traceable to the data, the template and the user that produced it — creating a complete, auditable record.
Full automation for ops
Invoices, renewal notices and onboarding packets go out automatically — triggered by Flow, no user action required.
The two approaches to Salesforce document generation
Before building anything, understand the two fundamentally different architectures. They have very different implications for security, reliability and long-term maintenance.
| Factor | Connector-based tools | Native generation (Dochly) |
|---|---|---|
| Data location | Leaves Salesforce's trust boundary on every generation | Stays within Salesforce's security and compliance boundary |
| Permissions | Managed separately in the vendor's system | Uses existing profiles, permission sets and sharing rules |
| Reliability | Depends on external API uptime | No external credentials or API connections to manage |
| Audit trails | May live in the vendor's system, not yours | Stored on the Salesforce record |
| Automation | Custom Apex or webhooks for full integration | Works directly with Flow and approvals — no custom code |
| Pricing | Per-document or per-user fees escalate at scale | No per-document fees or external dependencies |
| Who builds it | Often needs a developer | Built by an admin |
For regulated industries — healthcare, financial services, legal, government — native generation keeps sensitive data within Salesforce's compliance boundary. Install Dochly from AppExchange and connect to your org in minutes.
Step 1: Define your document types
Map out the documents your team generates regularly before building anything. This surfaces data model gaps, template complexity and trigger requirements upfront — and saves significant rebuilding later.
Sales documents
Quotes, proposals, order confirmations and pricing sheets — typically based on the Opportunity object with related Line Items.
Legal documents
Contracts, NDAs, master service agreements and amendments — often requiring conditional clauses based on deal type, region or tier.
Financial documents
Invoices, statements, renewal notices and payment receipts — often triggered by scheduled batch processing on a monthly cycle.
HR documents
Offer letters, employment agreements and policy acknowledgments — typically triggered when a Candidate or Contact status changes.
Compliance documents
Case summaries, audit reports and regulatory filings — requiring complete audit trails and secure compliance document storage.
Operational documents
Statements of work, project plans and onboarding packets — often multi-section documents pulling from Account, Contact and custom objects.
For each document type, note which object it's based on, which related objects it pulls from, whether content varies by record data, who or what triggers it, and where the output goes. This mapping drives every template and automation decision that follows.
Step 2: Build your document templates
The template is the foundation of your document generation workflow. The Dochly template editor lets you build templates entirely inside Salesforce — inserting merge fields, applying formatting, adding conditional sections and previewing with real record data before publishing.
A. Working with merge fields
Merge fields tell the template where to insert data from the Salesforce record. A merge field for account name might look like {{Account.Name}}. When the document generates, that placeholder is replaced with the actual value.
You can use merge fields for standard fields (Account Name, Opportunity Amount, Contact Email), custom fields on any object, related object fields (Opportunity Line Items, child Contacts), formula fields, and date/time fields with formatting options.
B. Using conditional logic in templates
Conditional logic separates a powerful generation tool from a basic mail merge. Dochly's conditional document logic lets the template respond to its data — showing a liability limitation clause only for Enterprise contracts, adding a data processing addendum only for EU billing countries, or showing a payment plan section only when terms are installment-based.
With conditional logic, one master template handles dozens of variations. See the guides to creating a contract template and a proposal template.
C. Building dynamic tables for line items
Most sales and financial documents include line item tables that vary by deal. A quote template pulling from Opportunity Line Items generates exactly as many rows as there are products — no manual counting, no blank rows, no overflow. Totals are calculated and formatted automatically.
Step 3: Set up document generation triggers
Once templates are ready, define how and when documents get generated. A native Salesforce tool gives you four options, each suited to a different level of automation.
Button click — user triggered
Add a custom button to a record page. The user clicks "Generate Quote," selects the template, and the document is created and attached. Best for documents needing human judgment first — proposals, custom statements of work.
Salesforce Flow — fully automated
Generate from a Flow when a stage changes, a checkbox is checked, a date is reached or an approval completes. Fully hands-off — generated, attached and emailed automatically. See how to trigger from Salesforce Flow.
Approval process integration
Generate from the final step of an approval chain. Example: a quote passes internal pricing approval, and the customer-facing contract is generated and sent for e-signature the moment approval is granted.
Scheduled batch processing
For monthly invoices, weekly reports and quarterly renewal notices, batch processing generates documents for hundreds or thousands of records in one run. See how to schedule automatic generation.
Step 4: Configure document delivery
Generating the document is only half the workflow. You also need to define what happens after it's created — and a native platform handles all four delivery types inside Salesforce.
Attach to record
The document is saved as a Salesforce File on the record that triggered it — accessible to anyone with record access. Documents are stored automatically.
Email to contact
The document is attached to an email sent through Salesforce — logged on the Activity timeline, tracked for opens if email tracking is enabled, and subject to your org's delivery settings.
Send for e-signature
Generation triggers a signature request automatically. With Dochly's native e-signature, signing runs inside Salesforce — see the send for e-signature guide.
Stored with retention policy
Store compliance-sensitive documents in specific Files libraries with retention policies, so they are kept for required periods and ready for audits. See compliance document management.
Step 5: Test before you go live
Test thoroughly before rolling document generation out to users. Run through this checklist:
- Generate test documents from records with complete data — verify every merge field populates correctly.
- Generate from records with missing or null fields — confirm blanks are handled gracefully, with no "null" text in the document.
- Test all conditional logic branches — create records that trigger each condition and verify the right content appears.
- Trigger every Flow path and confirm documents generate as expected in each scenario.
- Test batch jobs with a small record set before running at full scale — verify attachments and email delivery.
- Test as different user profiles — confirm users can only generate documents they should have access to.
- Verify field-level security is respected — restricted fields should not appear for users without access.
- Run a complete end-to-end test — trigger, generate, approve, sign, store and verify post-signature automation in one pass.
Edge cases cause the biggest problems. Everything that can happen in production should be tested before it does — including rare scenarios that cause significant issues when they occur.
Common Salesforce document generation use cases
These four workflows run natively inside Salesforce with zero manual steps. Each follows the same pattern: a trigger, generation, delivery and a follow-up action.
Sales quote generation
Opportunity reaches "Proposal Ready" → Flow generates the quote with line items and conditional pricing → Quote attached and emailed to the primary contact → 7-day reminder sends if unsigned
Automated invoice run
Scheduled job fires on the 1st of the month → Batch generates invoices for Opportunities closed in the prior 30 days → Invoices attached and emailed to billing contacts → Invoice status tracked on a custom object
Contract generation at close
Opportunity moves to "Closed Won" → Flow generates the MSA with conditional clauses by contract type and billing country → Sent for e-signature → Signed contract stored and stage updated to "Contract Executed"
Onboarding document delivery
New Account created with Status = Active Customer → Flow generates a welcome packet with account-specific service details → Emailed to the primary contact → Follow-up task created for the account owner
Why native document generation beats manual processes every time
A typical manual document process takes 20 to 40 minutes per document — finding the template, copying data from Salesforce, formatting, exporting, emailing and re-uploading the signed copy. The time cost compounds fast.
| Metric | Manual process | Native generation (Dochly) |
|---|---|---|
| Time per document | Up to 40 minutes | Under 1 minute |
| What the user does | Create, format, send, re-upload | Generate, attach, email, e-sign — automatically |
| Time for 60 documents/month | About 40 hours | Under 1 hour — 39 hours reclaimed* |
*Nearly a full week of selling time returned every month for a team generating 60 documents.
The result:
- Faster sales cycles
- Zero data entry errors
- Full compliance audit trail
- Real-time document status
- Data stays in Salesforce
- Scales with your volume
Dochly by UTECH HUB — Install Free
Templates, merge fields, triggers, delivery and e-signature — all native inside Salesforce.
Install on AppExchangeGenerating documents in Salesforce: FAQs
Generating documents in Salesforce doesn't have to mean exporting data, reformatting in Word and manually tracking what went where. With Dochly's native document generation, the entire process — template, merge fields, conditional logic, triggers, delivery and storage — happens inside Salesforce, tied directly to the records that matter. The five steps in this guide take you from manual document chaos to a fully automated workflow.
Explore Dochly pricing, see real customer results, or read how to automate contracts in Salesforce. Your data is already in Salesforce — it's time to put it to work.