Help Center Template Editor Create an Invoice Template

Create an Invoice Template in Salesforce with Dochly

Updated June 2026 10 min read Template Editor
An invoice template in Dochly generates accurate, fully formatted invoices directly from Salesforce Opportunity data — line items, quantities, pricing, tax, payment terms, and billing contact details all populated automatically. No manual data entry, no formatting in Excel, no emailing PDFs from outside Salesforce. This guide covers building a complete invoice template from header to footer, handling tax calculations, connecting to batch automation for monthly invoice runs, and delivering invoices to billing contacts automatically.

What is a Salesforce invoice template?

A Salesforce invoice template in Dochly is a reusable invoice structure that pulls line items, pricing, billing details, and payment terms directly from Salesforce records at generation time. Every invoice generated from the template is accurate, consistently formatted, and stored as a Salesforce File on the originating record — no manual steps required.

Dynamic line item table

Pulls from Opportunity Products automatically — expands to fit any number of line items without manual adjustment.

Automatic totals

Subtotal, tax, discounts, and total amount pulled directly from Salesforce fields — no manual calculation needed.

Batch generation

Generate invoices for hundreds of Opportunities in a single scheduled Flow run — monthly billing cycles automated entirely.

Automated delivery

Invoices delivered to billing contacts via email automatically — no rep action required after the template is published.

Conditional tax sections

Tax lines appear or hide based on account region, tax-exempt status, or product type — handled by conditional logic.

Stored on the record

Each generated invoice attaches to the Salesforce Opportunity as a File — instantly accessible for audit and re-sending.


Invoice types you can build

Use the same template creation process for any invoice type — the difference is which fields and conditional sections you include.

Standard Invoice — one-time payment for closed Opportunity
Recurring Invoice — monthly or annual subscription billing
Milestone Invoice — partial billing tied to project milestones
Deposit Invoice — upfront payment request before work begins
Credit Note — adjustment or reversal of a previous invoice
Tax Invoice — VAT/GST compliant invoice for regulated regions

Before you build

Invoice templates are data-heavy — every field must map to a real Salesforce value. Confirm the following before opening the template editor:

Opportunity Products set up

Your invoice line items pull from Opportunity Products (Order Items). Confirm Products and Price Books are configured in your Salesforce org and that sales reps consistently add products to Opportunities.

Tax fields confirmed

Identify how tax is stored in your org — a custom Tax__c field on the Opportunity, a formula field, or a tax amount on each line item. This determines how you build the totals section.

Billing contact identified

Know which Contact record holds the billing contact for each account — this may be a custom field (Billing_Contact__c) or the primary Contact on the Opportunity depending on your org setup.

Invoice numbering defined

Decide how invoice numbers are generated — a custom auto-number field on the Opportunity, a formula field, or a sequential number field. This must exist in Salesforce before building the template.

Dochly
Available on Salesforce AppExchange Dochly by UTECH HUB — Install Free

100% native Salesforce invoice generation & automation


Step-by-step: building your invoice template

1

Create and name the template

Open the Dochly app in Salesforce. Go to Templates → New Template. Name your template clearly — for example "Standard Invoice" or "Recurring Invoice — Monthly". Select Opportunity as the primary object — this gives you access to Opportunity fields, Account fields, Contact fields, and Opportunity Line Items.

See the foundational guide: Create a document template in Salesforce with Dochly

2

Build the invoice header

The invoice header contains your company branding and the document title. Use a two-column layout — logo on the left, invoice reference details on the right:

[Company Logo] INVOICE

Invoice #: {{Opportunity.Invoice_Number__c}}
Invoice Date: {{TODAY | date: "MMMM d, yyyy"}}
Due Date: {{Opportunity.Payment_Due_Date__c | date: "MMMM d, yyyy"}}

For header branding: Build a branded document template

3

Build the "Bill To" section

The Bill To section identifies the customer being invoiced. Pull billing details from the Account and Contact records associated with the Opportunity:

BILL TO
{{Account.Name}}
{{Contact.FirstName}} {{Contact.LastName}}
{{Account.BillingStreet}}
{{Account.BillingCity}}, {{Account.BillingState}} {{Account.BillingPostalCode}}
{{Account.BillingCountry}}
{{Contact.Email}}

See the full field reference: Add Salesforce merge fields to a document template

4

Add the invoice details block

Below the Bill To section, add a compact reference block with deal and payment details — often laid out in a 2–3 column grid for clean scanability:

Purchase Order #: {{Opportunity.PO_Number__c}}
Contract Reference: {{Opportunity.Name}}
Payment Terms: {{Opportunity.Payment_Terms__c}}
Currency: {{Opportunity.CurrencyIsoCode}}
5

Build the line items table

This is the most important section of any invoice. Use a dynamic repeating table that pulls from Opportunity Products — the table expands to fit however many line items exist on the deal:

Description | Qty | Unit Price | Discount | Amount
---------------------|------|-------------|-----------|--------
{REPEAT OpportunityLineItems}
{{OpportunityLineItem.Name}} | {{OpportunityLineItem.Quantity}} | {{OpportunityLineItem.UnitPrice | currency}} | {{OpportunityLineItem.Discount}}% | {{OpportunityLineItem.TotalPrice | currency}}
{END REPEAT}

Right-align all numeric columns (Qty, Unit Price, Discount, Amount) and left-align the Description column. Add 6–8px cell padding for readability.

6

Build the totals section

The totals section appears below the line items table, right-aligned. It breaks down subtotal, discounts, tax, and the final amount due. This is how the totals block maps to Salesforce fields:

Subtotal{{Opportunity.Subtotal | currency}}
Discount- {{Opportunity.TotalOpportunityQuantity}} %
Tax ({{Opportunity.Tax_Rate__c}}%){{Opportunity.Tax_Amount__c | currency}}
Shipping{{Opportunity.Shipping_Amount__c | currency}}
Total Amount Due{{Opportunity.Amount | currency}}

The exact field names for Subtotal, Tax, and Shipping depend on how your Salesforce org is configured. If these custom fields don't exist, work with your admin to add them. Standard Opportunity fields include Amount and TotalOpportunityQuantity.

7

Handle tax with conditional logic

Not every invoice needs a tax line. Use conditional logic to show or hide tax sections based on account region, tax-exempt status, or product type:

{IF Account.Tax_Exempt__c = false}
Tax ({{Opportunity.Tax_Rate__c}}%): {{Opportunity.Tax_Amount__c | currency}}
{END IF}

{IF Account.BillingCountry = "United Kingdom"}
VAT Number: {{Account.VAT_Number__c}}
VAT (20%): {{Opportunity.VAT_Amount__c | currency}}
{END IF}

{IF Account.BillingCountry = "Australia"}
GST (10%): {{Opportunity.GST_Amount__c | currency}}
{END IF}
8

Add payment instructions

Every invoice needs clear payment instructions. This section is typically static — your bank details, payment methods accepted, and any online payment portal link. Add due date and late payment terms pulled from Salesforce:

PAYMENT INSTRUCTIONS

Payment Due: {{Opportunity.Payment_Due_Date__c | date: "MMMM d, yyyy"}}
Payment Terms: {{Opportunity.Payment_Terms__c}}

Bank Transfer:
Bank Name: [Your Bank Name]
Account Name: [Your Company Name]
Account Number: [Your Account Number]
Sort Code / SWIFT / IBAN: [Your Details]

Reference: {{Opportunity.Invoice_Number__c}}
9

Add footer and legal notices

The invoice footer should include your company's registered details, VAT or tax registration numbers where required, and any late payment notice. Use the special page number merge fields for multi-page invoices:

[Company Name] | [Registered Address] | [Registration Number]
{IF Account.BillingCountry = "United Kingdom"}
VAT Registration: [Your VAT Number]
{END IF}
Page {{PAGE}} of {{TOTAL_PAGES}}
10

Preview, test, and publish

Test the invoice template from multiple real Opportunity records before publishing. Verify these specific scenarios:

  • An Opportunity with multiple line items (5+) — confirm table expands correctly
  • An Opportunity with a discount — confirm discount line appears in totals
  • A UK account — confirm VAT section appears and VAT number shows
  • A tax-exempt account — confirm tax section is hidden
  • An Opportunity with a missing due date field — confirm no "null" appears

For troubleshooting issues: Template editor troubleshooting guide


Batch invoice automation

The most powerful use of an invoice template is batch automation — generating invoices for all eligible Opportunities in a single scheduled run instead of one by one. This is how a monthly invoice run works end to end in Salesforce:

1
Scheduled Flow runs on the 1st of each month

A time-triggered Salesforce Flow collects all Opportunities with Stage = "Closed Won" and Invoice_Status__c = "Pending" closed in the previous 30 days.

2
Dochly batch generation triggered

The Flow triggers Dochly to generate invoices for all collected Opportunities simultaneously — one invoice per record, using the published invoice template.

3
Invoices generated and attached

Each invoice is generated with that Opportunity's live data and attached as a Salesforce File on the respective record — no manual intervention required.

4
Invoices emailed to billing contacts

Dochly emails each invoice to the billing contact on the Opportunity automatically — with the invoice PDF as an attachment.

5
Invoice status updated on each Opportunity

The Flow updates Invoice_Status__c from "Pending" to "Sent" on each processed Opportunity — giving finance teams a live view of invoice status without leaving Salesforce.

Batch invoice automation is the most common high-volume use case for Dochly across finance and operations teams. A sales team processing 200 invoices per month manually (20–30 minutes each) can reduce that to a single scheduled job that runs in minutes. See the guide on managing multiple document templates for organizing invoice template variants by billing cycle or region.


Invoice template best practices

  • Always include an invoice number field — create an auto-number field on the Opportunity object if one doesn't exist. Invoices without unique reference numbers create reconciliation problems for your customers.
  • Include both invoice date and due date — pull invoice date from TODAY and due date from a custom Payment_Due_Date__c field. Never leave due date blank on a generated invoice.
  • Use conditional logic for tax — different regions, tax-exempt accounts, and product types all have different tax requirements. Handle all variants in one template rather than creating separate invoice templates per region.
  • Include your company's legal registration details — especially for VAT/GST invoices, include registration numbers in the footer. Invoices missing required legal details may not be accepted by your customers' accounts payable teams.
  • Version your invoice template — when your pricing structure or legal details change, create a new version rather than overwriting. Historical invoices must reflect the terms in effect when they were issued. See editing and updating existing templates.
  • Validate required fields before generation — add a Salesforce validation rule or Flow check to ensure Invoice_Number__c and Payment_Due_Date__c are populated before an invoice can be generated.

Frequently asked questions

Yes. Build a Salesforce Flow that triggers when Opportunity Stage changes to "Closed Won" and connect it to Dochly's document generation action. The invoice generates automatically and attaches to the record — no manual action required from the sales rep.
Yes. Dochly's batch processing capability lets you generate documents for hundreds or thousands of records in a single scheduled Flow run. This is specifically designed for monthly invoice runs, renewal notices, and other high-volume generation workflows.
If your Salesforce org has multi-currency enabled, Dochly picks up the currency from the Opportunity's CurrencyIsoCode field and formats amounts accordingly using the currency formatting option. Use conditional logic to display different currency symbols or formats based on the billing country if needed.
Yes. Configure the Dochly document generation action in your Salesforce Flow to email the generated invoice to a specified contact — the primary contact, a billing contact lookup field, or any email address stored on the record.
Generated invoices are stored as Salesforce Files attached to the Opportunity record that triggered generation. They are immediately accessible to anyone with record access and can be re-sent or downloaded at any time without leaving Salesforce.

Your invoice template is ready to generate accurate, tax-compliant invoices automatically from any Salesforce Opportunity. Next steps: Edit and update an existing template · Manage multiple templates · Troubleshooting guide

Dochly
Salesforce AppExchange — UTECH HUB Install Dochly on AppExchange

Rated 5 stars · Native Salesforce app · Free to install