Help Center Document Generation Generate from Any Record

How to Generate a Document from Any Salesforce Record with Dochly

Updated June 2026 7 min read Document Generation
Dochly generates documents from any Salesforce object — not just Opportunities. Every standard object and every custom object in your org can serve as the primary record for document generation. This guide covers how generation works across different object types, how to set up templates for standard and custom objects, how to pull cross-object data into documents, and how to add the Generate Document button to any page layout in Salesforce.

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

Opportunity

Proposals, quotes, invoices, order confirmations, renewal agreements. The most commonly used object for document generation.

Account

Account

Account summaries, welcome letters, annual statements, compliance reports, relationship-level agreements.

Contact

Contact

HR documents, onboarding letters, NDA agreements, personal correspondence directed at individuals.

Contract

Contract

Contract renewals, amendments, addenda, and documents that are directly tied to a Salesforce Contract record.

Case

Case

Case closure summaries, resolution letters, escalation reports, regulatory compliance documentation.

Custom objects

CustomObject__c

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:

1

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.

2

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.

3

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.

1
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.

2
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.

3
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.

4
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.

Parent object fields

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.

Child object / related list data

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.

Sibling object fields

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 relationship fields

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.

What the generating user CAN do

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.

What the generating user CANNOT do

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:

1

Open the page layout in Setup

Go to Salesforce Setup → Object Manager → [Object Name] → Page Layouts → [Layout Name]. The Lightning page layout editor opens.

2

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.

3

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

Yes. Enable the custom object in Dochly Settings → Object Access, create a template with the custom object as the primary object, and use the relationship name to traverse to the parent Opportunity for its fields — e.g. {{CustomObject__c.Opportunity__r.Name}}. The full Opportunity data is accessible through the parent relationship.
No. Each template is tied to one primary object. A template built for Opportunity can only generate from Opportunity records — it won't appear in the template picker on an Account record page. If you need the same document structure for multiple objects, duplicate the template and change the primary object for each copy.
Traverse the relationship chain in the merge field syntax. For example, from a Contact record, to get the Account's parent Account name: {{Contact.Account.ParentAccount.Name}}. Dochly resolves relationship chains at generation time. The merge field picker shows relationship traversal options when you navigate the field tree — use it to build the path rather than typing it manually.
Custom objects must be manually added to Dochly's object access list before they appear as options. Go to Dochly → Settings → Object Access → Add Object and enter the exact API name of the custom object (e.g. Project__c). After saving, the object appears in the Primary Object dropdown when creating or editing a template.

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.

Dochly
Salesforce AppExchange — UTECH HUB Install Dochly on AppExchange

Rated 5 stars · Native Salesforce app · Free to install