For admins and template authors: build a Generate Receipt button on a custom Receipt object that creates a numbered PDF receipt for a payment, with the payer's details, the amount paid and the balance still due, and saves it to the receipt's Files. It takes about 30 minutes, including creating the object.
What you'll build
For a sample receipt of a $20,000 payment against the Burlington Textiles Weaving Plant Generator opportunity, the receipt reads:
RECEIPT RCT-0007 · Date: 11/20/2026 Received from: Burlington Textiles Corp of America, Burlington, NC 27215 For payment of: Burlington Textiles Weaving Plant Generator · Paid by: Check
| Opportunity amount | $62,000.00 |
| This payment | $20,000.00 |
| Balance due | $42,000.00 |
Balance remaining: $42,000.00. Thank you for your payment. The file is saved as Receipt RCT-0007.pdf.
It uses these features:
- Lookup merge fields through custom relationships (
Account__r,Opportunity__r); see Template syntax basics - CurrencyCulture for the amounts
- Date format for the receipt date
- IF conditions for the paid-in-full message
- Convert to PDF?, Filename (ofn) and bgm=1 to save a named PDF
All of these work in both Basic and Pro.
Before you begin
- Docs Made Easy is installed and you have a license and the permission set. See Assign licenses and permission sets.
- You can open Document Setup, create custom objects and fields, and edit page layouts.
- You have an account with a billing address and an opportunity with an Amount, to test with.
- Your org has a Receipt custom object. If it doesn't, create it in Salesforce Setup > Object Manager > Create > Custom Object:
- Label
Receipt, Object NameReceipt(API nameReceipt__c). - Record Name
Receipt Number, Data Type Auto Number, Display FormatRCT-{0000}. Auto Number keeps receipt numbers unique without anyone typing them. - Select Launch New Custom Tab Wizard after saving this custom object, so users can open receipts from a tab.
- Label
- On Receipt, create these fields in Fields & Relationships > New:
| Field label | Data type | API name | Holds |
|---|---|---|---|
| Account | Lookup Relationship (Account) | Account__c | Who paid |
| Opportunity | Lookup Relationship (Opportunity) | Opportunity__c | What the payment is for |
| Receipt Amount | Currency | Receipt_Amount__c | The amount of this payment |
| Balance Due | Currency | Balance_Due__c | What is still owed after this payment |
| Payment Method | Picklist (Cash, Check, Card) | Payment_Method__c | How the customer paid |
If your org already has a receipt or payment object, use its fields and copy their tags from the Merge Field Helper.
1. Build the template
Download the sample template (.docx), ready to upload, or create a Word document with the content below. Replace anything in [square brackets] with your own details.
RECEIPT {{Receipt__c.Name}}
Date: {{Receipt__c.CreatedDate \@ "MM/dd/yyyy"}}
Received from:
{{Receipt__c.Account__r.Name}}
{{Receipt__c.Account__r.BillingCity}}, {{Receipt__c.Account__r.BillingState}} {{Receipt__c.Account__r.BillingPostalCode}}
For payment of: {{Receipt__c.Opportunity__r.Name}}
Paid by: {{Receipt__c.Payment_Method__c}}
[Word table: 2 columns, 3 rows, aligned right.]
| Opportunity amount | {{Receipt__c.Opportunity__r.Amount \# CurrencyCulture1}} |
| This payment | {{Receipt__c.Receipt_Amount__c \# CurrencyCulture1}} |
| Balance due | {{Receipt__c.Balance_Due__c \# CurrencyCulture1}} |
{{IF|Receipt__c.Balance_Due__c|GT|0}}
Balance remaining: {{Receipt__c.Balance_Due__c \# CurrencyCulture1}}. Thank you for your payment.
{{ELSE}}
Paid in full. Thank you for your payment.
{{ENDIF}}
Received by: {{Receipt__c.CreatedBy.Name}}
To turn this into a Word template:
- Paste the text into a new Word document. Replace the
[Word table …]block with a real Word table that has the same rows and cells. - Keep each tag exactly as written, in one piece.
- Check the API names against your org. When you upload the template in step 2, open the Merge Field Helper, select a lookup field such as Account Id to see the account's fields, and check that each tag matches, for example
{{Receipt__c.Account__r.BillingCity}}. See Where to get merge fields.
The IF block shows the remaining balance when Balance Due is more than 0, and "Paid in full" otherwise. Every {{IF}} needs its {{ENDIF}}.
{{Receipt__c.CreatedBy.Name}} merges the name of the user who created the receipt. The Merge Field Helper offers standard lookups such as Created By on custom objects too.
2. Create the solution
- In Docs Made Easy, open Document Setup and click Launch Wizard.
- On Add Details, enter
Generate Receiptas the Button Name, select Receipt and click Create. The Gather Data page opens. - Click Next. The template reads the account and opportunity through the receipt's lookup fields, so you don't add anything here.
- Click Add templates and choose Upload a document (before v1.25: Create New Document Template). Use the Merge Field Helper to check the receipt and lookup tags.
- Enter
Receiptas the Template Name, upload your Word file and click Save. Click Next. The Assign Behaviors page opens.
Each wizard screen is described in Create a template with the Document Automation Wizard.
3. Set the behaviors
On the Assign Behaviors page, set the following. Click Save in each section, then click Next.
| Section | Setting | Value | Why |
|---|---|---|---|
| Generated File | Convert to PDF? | On | Customers get a receipt they can't edit. |
| Generated File | Filename | Receipt {!Receipt__c.Name} | Each file is named after its receipt number, so it's easy to find. |
| Background Mode | Would you like to enable background mode? | On, with File (bgm=1) | One click saves the PDF to the receipt's Files and downloads a copy. |
| Other Parameter | CurrencyCulture1 | en-US | Formats the amounts as US dollars with separators and two decimals, for example $20,000.00. Use the culture code for your currency. |
The space in the file name is kept, and .pdf is added automatically, so the file is saved as Receipt RCT-0007.pdf.
4. Add the button
- On the last wizard page, click Go to Page Layouts and open Receipt Layout.
- From Mobile & Lightning Actions, drag Generate Receipt into Salesforce Mobile and Lightning Experience Actions.
- Click Save.
If users don't see the button, see Users can't see or use the button.
5. Generate and check
Create a receipt: pick an account and an opportunity, and enter
20000as Receipt Amount, the remaining amount as Balance Due and a Payment Method. Save it.Click Generate Receipt. Background mode skips the Composer page, and the PDF downloads.

Check the receipt against the record:
- The receipt number matches the record's Receipt Number.
- The account name and address come from the account, and the opportunity name and amount from the opportunity.
- The amounts show the currency symbol for your
CurrencyCulture1. - With Balance Due more than 0, the remaining balance is shown. Set it to
0, generate again, and "Paid in full" is shown.
On the receipt's Related tab, open Files.
Receipt RCT-0007.pdf(with your receipt number) is listed.
Troubleshooting
| What you see | Fix |
|---|---|
An account or opportunity value is blank, or a tag such as {{Receipt__c.Account__r.Name}} shows as text | The lookup is empty on the receipt, the API name is wrong or you can't see the field. Copy the tag from the Merge Field Helper. See Merge fields are blank or show as text and DME-SF-002. |
| An error says the object doesn't exist or isn't accessible | Your profile or permission set can't read Receipt or one of its fields. Grant access in Salesforce. See DME-SF-003. |
| Amounts have no currency symbol, or the date is in the wrong format | Add CurrencyCulture1 as an Other Parameter and \# CurrencyCulture1 to each amount tag; check the date pattern's letter case. See Wrong date, number or currency format. |
| "Paid in full" never appears | Balance Due is empty or above 0. The IF compares the field with 0, so enter 0 when the payment clears the balance. |
| The PDF layout differs from the Word file | Fonts or floating objects change in conversion. See The PDF looks different from my Word template. |
Take it further
- Choose where the file goes: save to Notes & Attachments, Chatter or only download. See Where generated documents are saved.
- Email the receipt to the payer: add an email template to the solution and set recipients under Assign Behaviors > Email. See Create a template with the Document Automation Wizard and directemailsender.
- Get the receipt countersigned (Pro): add signature tags to the template before you upload it, or in the Template Editor. See Generate and send documents for eSignature.
- Send a receipt every time a payment is recorded (Pro): Automate document generation with Flow, triggered when a Receipt record is created.
- Bill before you receipt: Generate an invoice from an opportunity.