On-Demand Document
An on-demand document in Salesforce is a PDF, Word, or other formatted file generated at runtime from data in the org, in response to a user action or automated trigger.
Definition
An on-demand document in Salesforce is a PDF, Word, or other formatted file generated at runtime from data in the org, in response to a user action or automated trigger. The pattern shows up across CPQ (quotes and proposals from the Document Designer), OmniStudio (Document Template Source for guided journeys), Service Cloud (case correspondence), and Sales Cloud (mail merge templates). The shared idea is that the document does not exist as a stored file until someone needs it; the system builds it from a template plus current data on demand.
This approach contrasts with static documents that are uploaded once and referenced repeatedly. On-demand generation guarantees that every document reflects the latest data: a quote re-generated five minutes after a price change shows the new price; a case correspondence regenerated after a status update shows the new status. The trade-off is server cost and a few seconds of latency on each generation. Salesforce offers several engines (Conga, Salesforce Document Generation, OmniStudio Document Template, Visualforce PDF) so admins can pick the right tool for the use case.
How on-demand documents get built across Salesforce engines
CPQ Document Designer for quotes and proposals
CPQ ships with the Document Designer, a drag-and-drop tool that lets sellers build quote templates with conditional sections, dynamic tables of line items, terms and conditions, and branded cover pages. When a sales rep clicks Generate Document on a Quote, Salesforce assembles the PDF in real time using the current quote lines, prices, discounts, and terms. The output is stored as a ContentDocument on the Quote, but the file is re-generated on every click unless the rep checks Save to Quote.
OmniStudio Document Template Source
Industries clouds use the OmniStudio Document Template Source object to define template DOCX or PDF files with merge fields. An OmniScript action element (Document Template Action) calls the engine, passes the OmniScript runtime JSON in, and gets back a generated document the user can download or email. Common patterns include welcome letters after onboarding, summary of benefits after a health insurance enrollment, and confirmation receipts after a financial transaction.
Conga, Nintex, and AppExchange options
Many enterprise orgs use Conga Composer, Nintex DocGen, or S-Docs for advanced document generation. These AppExchange tools offer richer template languages, support for Word and Excel output, batch generation, and e-signature integration. They are subscription products separate from Salesforce platform licensing. Pick a third-party engine when the use case needs Word output that finance can edit, batch generation across thousands of records, or e-signature workflow tied to the document.
Visualforce PDFs and standard PDF rendering
Before declarative document tools matured, developers built PDFs by writing Visualforce pages with renderAs="pdf". The platform converts the rendered HTML into a PDF when the user accesses the page. This pattern is still widely used in legacy orgs for invoices, contracts, and reports. It is cheap (free with the platform), flexible (full Visualforce control), but tedious to maintain (HTML and CSS hand-coding).
Field merge, conditional sections, and tables
Every on-demand document engine supports three core capabilities. Field merge replaces template placeholders with current record field values. Conditional sections show or hide blocks of content based on logic (Show this paragraph if Country equals US). Tables render rows for related records (line items, attendees, transactions). Beyond these core capabilities, engines differ in their support for nested tables, multi-column layouts, headers and footers, page numbering, and digital signatures.
Storage, audit, and retention
Generated documents are typically saved as ContentDocument records on the originating record (Quote, Case, Contract). Each generation is a new version, so the audit trail shows every iteration the user produced. For compliance-heavy industries, configure Field Audit Trail on the document name and version fields, and consider sending generated documents to an external archive (S3, Box) at the same time, since Salesforce file storage limits can fill quickly if every quote draft is retained forever.
How to set up on-demand document generation for a quote
The most common on-demand document use case is a CPQ quote PDF. Set it up by building a template in the CPQ Document Designer, mapping merge fields to Quote data, and adding the Generate Document button to the page layout.
- Build the template in Document Designer
Setup > Document Designer > New Template. Drag content blocks (text, tables, images, page break) onto the canvas. Insert merge fields by typing the field API name in curly braces. Add conditional sections for clauses that should appear only when criteria are met.
- Test against a sample quote
From the Document Designer, click Preview. Pick a real Quote in the sandbox. Verify the merged values look right and conditional sections fire as expected. Iterate the template until the output is correct.
- Add the Generate Document button to the Quote layout
Object Manager > Quote > Page Layouts. Drag the Generate Document button into the Salesforce Mobile and Lightning Experience Actions section. Save the layout.
- Wire up storage and naming convention
Decide where generated documents go (ContentDocument on Quote, an external library, a synced folder). Configure the file naming convention to include Quote Name, Date, and Version so files do not collide.
- Test end to end
Open a Quote, click Generate Document, confirm the PDF matches expectations, save it to the Quote, regenerate to verify the version increments correctly.
Native, no extra license. Best for quotes and proposals in a CPQ-licensed org.
Best for Industries cloud workflows. Triggered from OmniScripts and Integration Procedures.
Free, code-based. Good for legacy or highly customized PDFs that simple templates cannot produce.
Premium AppExchange. Rich template language, e-signature, batch generation. Best for complex enterprise use cases.
Competing AppExchange tools. Pick based on existing vendor relationships and feature set.
- Generated documents count toward file storage limits. A busy CPQ org generating thousands of quote PDFs per month can exhaust org storage; offload to external archive or set a retention policy.
- Document Designer templates do not support every Salesforce field type cleanly. Multi-select picklists, rich text fields, and encrypted fields may merge as raw values or fail to render. Test edge cases.
- Conga and other third-party engines have their own callout limits and API quotas. Batch generation can hit those before the underlying Salesforce limits; monitor vendor dashboards in parallel.
- E-signature workflows tied to generated documents (DocuSign, Adobe Sign) require the generated file to be stored, not just rendered transiently. Save to Quote (or equivalent) before sending for signature, or the signed copy will not link back to the source record.
Trust & references
Cross-checked against the following references.
- CPQ Quote TemplatesSalesforce Help
- OmniStudio Document TemplatesSalesforce Help
Straight from the source - Salesforce's reference material on On-Demand Document.
- CPQ Document Designer DocumentationSalesforce Help
- Visualforce renderAs PDFSalesforce Developers
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What is an On-Demand Document?
Q2. What problem does it solve?
Q3. What are typical use cases?
Discussion
Loading discussion…