How to Generate a Document from Any Salesforce Record with Dochly
Which Salesforce objects support document generation
Dochly can generate documents from any Salesforce object that has been enabled in the Dochly object access settings. Standard objects are enabled by default. Custom objects must be added manually in Dochly Settings → Object Access before they appear in the template editor.
Opportunity
Proposals, quotes, invoices, order confirmations, renewal agreements. The most commonly used object for document generation.
Account
Account summaries, welcome letters, annual statements, compliance reports, relationship-level agreements.
Contact
HR documents, onboarding letters, NDA agreements, personal correspondence directed at individuals.
Contract
Contract renewals, amendments, addenda, and documents that are directly tied to a Salesforce Contract record.
Case
Case closure summaries, resolution letters, escalation reports, regulatory compliance documentation.
Custom objects
Any custom object in your org — project records, work orders, inspections, survey responses. Must be enabled in Settings first.
Document types by object
Different Salesforce objects naturally suit different document types. This reference table shows the most common document type pairings used by Dochly customers:
| Salesforce object | Common document types | Typical trigger |
|---|---|---|
| Opportunity | Proposal, Quote, Invoice, Order Confirmation, Renewal Notice | Stage change, button click, batch month-end |
| Account | Account Summary, Welcome Letter, Annual Statement, Credit Application | Onboarding Flow, quarterly batch, button click |
| Contact | NDA, Employment Offer, Onboarding Packet, Personal Agreement | HR Flow, button click |
| Contract | Renewal Agreement, Contract Amendment, Addendum | Expiry Flow, button click, batch 60-day run |
| Case | Case Summary, Resolution Letter, Escalation Report, Compliance Doc | Status change Flow, batch quarterly |
| Lead | Information Pack, Trial Agreement, Intro Letter | Lead conversion Flow, button click |
| Custom object | Work Order, Inspection Report, Project Brief, Survey Response | Custom Flow trigger, button click |
Generating from standard Salesforce objects
Standard Salesforce objects — Opportunity, Account, Contact, Contract, Case, Lead — are enabled in Dochly by default. No additional configuration is needed to use them as template primary objects. The process is the same regardless of which standard object you use:
Create a template with the correct primary object
In Dochly → Templates → New Template, set the Primary Object to the object you want to generate from. The primary object determines which fields are directly available as merge fields and which related lists are accessible in the template editor.
Add merge fields using the field picker
Use the merge field picker in the template editor toolbar to browse and insert fields from the primary object and its related objects. Fields are organized by object — select the primary object first, then navigate to related objects for cross-object data.
Set the template to Active and add the button to the page layout
Once the template is built and tested, set it to Active. Then add the Generate Document button to the page layout of the relevant object so users can generate from the record page. See Add a document generation button.
Generating from custom objects
Custom objects require one extra setup step before they can be used as a template primary object — they must be added to Dochly's object access list. Once added, they work exactly the same as standard objects.
Add the custom object to Dochly's object access list
Go to Dochly → Settings → Object Access. Click Add Object and enter the custom object's API name (ending in __c, e.g. Project__c). Save. The object is now available as a primary object in the template editor.
Create a template with the custom object as primary object
In Dochly → Templates → New Template, the custom object now appears in the Primary Object dropdown. Select it. All fields on the custom object are available in the merge field picker.
Add the Generate Document button to the custom object page layout
In Salesforce Setup → Object Manager → [Your Custom Object] → Page Layouts → [Layout Name] → Buttons, drag the Dochly Generate Document button into the layout. Save. The button now appears on the custom object's record pages.
Assign the Dochly User permission set to users generating from the custom object
Users who need to generate documents from the custom object must have the Dochly User (or Dochly Admin) permission set. See Connect Dochly to your Salesforce org for permission set assignment steps.
Custom object API names always end in __c (e.g. Work_Order__c). Find the exact API name in Salesforce Setup → Object Manager → [Object] → Details → API Name. Copy it exactly — it's case-sensitive.
Cross-object data in documents
When generating from any Salesforce record, your template can also include data from related objects — parent records, child records, and related lists. This makes it possible to generate a single document that combines data from multiple objects.
Fields from a parent object are available directly in the merge field picker. From an Opportunity template, you can include {{Account.BillingAddress}} to pull the Account's billing address into the document.
Use REPEAT blocks to include a dynamic table of child records — for example, all Contacts on an Account, or all Products on an Opportunity. See Generate from related lists.
From a Contact template, you can traverse to the Account (parent) and pull Account fields — e.g. {{Contact.Account.BillingCity}}. Dochly resolves the relationship path at generation time.
Custom lookup and master-detail relationships work the same way. Use the relationship API name (ending in __r) to traverse custom relationships — e.g. {{Project__c.Client__r.Name}}.
Field access and Salesforce security
Dochly fully respects Salesforce's security model — field-level security, object permissions, and record sharing rules all apply during document generation. Understanding how this works prevents common issues where documents generate successfully for admins but fail or show blank fields for regular users.
Generate documents from records they have read access to. Include fields from objects their profile has read permission on. Access related records within their sharing rules. Dochly generates using the running user's permissions — not admin-level access.
Include fields restricted by field-level security for their profile — those fields output blank. Generate from records not in their sharing visibility. Access objects their profile has no read permission on. Dochly never bypasses Salesforce security.
If a merge field shows correctly when an admin generates but is blank when a rep generates, the field is restricted by field-level security for the rep's profile. Fix it in Setup → Object Manager → [Object] → Fields & Relationships → [Field] → Set Field-Level Security → grant Read access to the rep's profile.
Adding the Generate Document button to any page layout
The Generate Document button can be added to any Salesforce object's page layout — standard or custom. The process is the same for every object:
Open the page layout in Setup
Go to Salesforce Setup → Object Manager → [Object Name] → Page Layouts → [Layout Name]. The Lightning page layout editor opens.
Find the Dochly button in the Buttons palette
In the page layout editor, look at the palette of available elements. Find the Buttons section and look for Generate Document (Dochly). If you don't see it, scroll down in the palette — installed package buttons appear at the bottom of the button list.
Drag the button into the Salesforce Mobile and Lightning Experience Actions section
Drag the Generate Document button from the palette into the Salesforce Mobile and Lightning Experience Actions section of the page layout. This is where quick action buttons appear at the top of the record page for users.
Save the page layout. Users with the Dochly permission set will now see the Generate Document button on every record of this type.
For a full walkthrough including screenshots and button visibility settings, see the dedicated guide: How to add a document generation button in Salesforce with Dochly.
Frequently asked questions
Dochly generates from any Salesforce object — standard or custom — with the same template-driven approach. Next in this series: Troubleshooting document generation errors in Salesforce — diagnose and fix the most common generation failures across all object types.
Rated 5 stars · Native Salesforce app · Free to install