For admins and template authors: build a Generate Contract button on the Contract object that turns a contract into a numbered PDF with the client's address, the customer signer, the contract term and a notice period, and saves it to the contract's Files. It takes about 20 minutes with the sample template.
What you'll build
For a sample contract with Burlington Textiles Corp of America, the first page of the PDF reads like this:
CONTRACT FOR SERVICES Contract number: 00000100
This Contract for Services is entered into on February 10, 2026 between [Your company name] (the "Service Provider") and Burlington Textiles Corp of America, 525 S. Lexington Ave, Burlington, NC 27215 (the "Client"), represented by Jack Rogers, VP, Facilities.
2. Contract term. This Contract starts on February 10, 2026 and continues for 3 months, until May 9, 2026 … 6. Termination. Either party may terminate this Contract by giving 30 days' written notice.
Contract 00000100 · Page 1 of 2 · File saved as
Contract 00000100.pdf
If the contract's Status isn't Activated, the number line reads "DRAFT, not for signature" instead.
It uses these features:
- Merge fields from the contract, its account and its signers, copied from the Merge Field Helper
- Date format (
\@) for readable dates - A conditional statement (
IF … ELSE … ENDIF) for the draft line - PAGE and NUMPAGES in the footer
- Default PDF, Output file name (ofn) and bgm=1 for a PDF saved to the record
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 create fields and edit the Contract page layout.
- You have contracts to test with. Fill in Account Name, Customer Signed By, Customer Signed Title, Contract Start Date, Contract Term (months) and Description (the template prints the description as the scope of work). Salesforce calculates Contract End Date from the start date and term.
- Create one custom field for the notice period:
- In Setup, open Object Manager > Contract > Fields & Relationships and click New.
- Choose Number, click Next, and enter
Notice periodas the Field Label,3as the Length and0as the Decimal Places. Salesforce sets the Field Name toNotice_period, so the API name isNotice_period__c. - Make the field visible to the profiles that generate contracts, add it to the Contract layout, and click Save.
- Optionally, fill in Company Signed By with the user who signs for your company.
Everything in this recipe, including the conditional statement, Convert to PDF? and background mode (bgm=1), works in both Basic and Pro. Only sending the contract for eSignature (in Take it further) needs Pro.
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.
[HEADER, right-aligned]
Contract {{Contract.ContractNumber}}
[BODY]
CONTRACT FOR SERVICES
{{IF|Contract.Status|EQ|Activated}}
Contract number: {{Contract.ContractNumber}}
{{ELSE}}
DRAFT, not for signature. Contract number: {{Contract.ContractNumber}}
{{ENDIF}}
This Contract for Services (the "Contract") is entered into on {{Contract.StartDate \@ "MMMM d, yyyy"}} (the "Effective Date").
BETWEEN
[Your company name], [your company address] (the "Service Provider")
AND
{{Contract.Account.Name}}, having its registered office at {{Contract.Account.BillingStreet}}, {{Contract.Account.BillingCity}}, {{Contract.Account.BillingState}} {{Contract.Account.BillingPostalCode}} (the "Client"), represented by {{Contract.CustomerSigned.Name}}, {{Contract.CustomerSignedTitle}}.
1. Scope of work
The Service Provider agrees to provide the following services to the Client:
{{Contract.Description}}
2. Contract term
This Contract starts on {{Contract.StartDate \@ "MMMM d, yyyy"}} and continues for {{Contract.ContractTerm}} months, until {{Contract.EndDate \@ "MMMM d, yyyy"}}, unless it is terminated earlier under section 6.
3. Payment terms
The Client agrees to pay the Service Provider [amount] [per month / on completion]. Each invoice is due within 30 days of the invoice date.
4. Obligations of the parties
- The Service Provider shall perform the services with due care and diligence.
- The Client shall provide timely cooperation and the information the Service Provider needs.
5. Confidentiality
Both parties agree to keep all confidential information private and not to disclose it to any third party without prior written consent.
6. Termination
Either party may terminate this Contract by giving {{Contract.Notice_period__c}} days' written notice.
7. Governing law
This Contract is governed by and interpreted in accordance with the laws of [state or country].
IN WITNESS WHEREOF, the parties have signed this Contract on the dates written below.
SERVICE PROVIDER: [Your company name]
Name: {{Contract.CompanySigned.Name}}
Signature: ______________________________
Date: ______________________________
CLIENT: {{Contract.Account.Name}}
Name: {{Contract.CustomerSigned.Name}}
Title: {{Contract.CustomerSignedTitle}}
Signature: ______________________________
Date: ______________________________
[FOOTER, centered]
Contract {{Contract.ContractNumber}} · Page {{PAGE}} of {{NUMPAGES}}
Create a Word document with this content. Lines in square brackets and capitals, such as [HEADER, right-aligned], tell you where the text goes; don't type them. Replace the other bracketed text, such as [Your company name], with your own wording. Type each {{…}} tag in one go, without changing its formatting halfway, so Word doesn't split it.
API names in your org can differ, especially for custom fields. Check each one in the Merge Field Helper when you upload the template (step 2): pick a field from the Account ID or Customer Signed By ID lookup to get the Contract.Account.… and Contract.CustomerSigned.… forms.
2. Create the solution
- In the Docs Made Easy app, click Document Setup, then click Launch Wizard.
- Enter
Generate Contractas the Button Name, select Contract and click Create. The Gather Data page opens. - Click Next. Account, Customer Signed By and Company Signed By are lookups on the contract, so you don't need to add relationships.
- Click Add templates and choose Upload a document (before v1.25: Create New Document Template). Enter
Contractas the Template Name, upload your Word file and click Save. Then click Next.
For a description of every wizard page, see Create a template with the Document Automation Wizard.
3. Set the behaviors
On the Assign Behaviors page, set these, clicking Save in each panel, then click Next:
| Setting | Value | Why |
|---|---|---|
| Generated File > Convert to PDF? | On | Contracts go out as PDF, so the layout can't be edited by accident. See Default PDF. |
| Generated File > Filename | Contract {!Contract.ContractNumber} | Every file carries the contract number and is easy to find. See Output file name. |
| Background Mode > Would you like to enable background mode? | On, with File (bgm=1) selected | One click saves the PDF to the contract's Files and downloads a copy. The Composer page is skipped. See bgm=1. |
The space in the file name is kept, and .pdf is added automatically, so the file is saved as Contract 00000100.pdf.
4. Add the button
- On the last wizard page, click Go to Page Layouts and open Contract Layout.
- From Mobile & Lightning Actions, drag Generate Contract into Salesforce Mobile and Lightning Experience Actions.
- Click Save.
If users still don't see the button, see Users can't see or use the Docs Made Easy button.
5. Generate and check
- Open a test contract and click Generate Contract. The PDF downloads.
- Check the PDF against the contract:
- The contract number in the header, the body and the file name matches Contract Number.
- Dates read like February 10, 2026, and the end date matches Contract End Date.
- The client name and address match the account's billing address.
- The notice period matches Notice period.
- The draft line appears only when Status isn't Activated.
- The footer shows the right page count, for example Page 1 of 2.
- On the contract's Related tab, open Files.
Contract 00000100.pdf(with your contract's number) is listed.
Your contract looks similar to this, with your own styling:

Troubleshooting
| What you see | Fix |
|---|---|
{{Contract.Notice_period__c}} appears as text, or a value is blank | The API name is wrong, the field is empty on the record, or you can't see the field. Copy the syntax from the Merge Field Helper and check field-level security. See Merge fields are blank or show as {{…}} text. |
| Dates show as 2026-02-10 | The \@ switch is missing from the tag. Add \@ "MMMM d, yyyy". See Dates, numbers or currency show the wrong value or format. |
| "Malformed conditional merge field" | The IF block is incomplete. Check it has the field, EQ, the value, {{ELSE}} and {{ENDIF}}. See DME-TPL-000. |
| The PDF's page breaks, fonts or page numbers differ from Word | See The PDF looks different from my Word template. |
| Nothing is saved to Files | Check that File (bgm=1) is selected and saved under Background Mode. See Where generated documents are saved. |
Take it further
- Save without downloading: add
SkipDownload1as an Other Parameter, andredirecttourl/{!Contract.Id}to return the user to the contract. See Where generated documents are saved for the other save locations. - Collect signatures (Pro): send the contract for eSignature with Sign Made Easy. The signature fields come from signature tags in the Word template: replace the
Signature: ____andDate: ____lines with signature tags before you upload the template, or add the tags later in the Template Editor. Signature tags aren't in the Merge Field Helper. See Generate and send documents for eSignature. - Email the contract: add an email template to the solution, or send the PDF in background mode without a preview with
directemailsenderand a Docs Made Easy email template. - Generate it automatically (Pro), for example when a contract is activated: Automate document generation with Flow.
- Contract for many accounts at once (Pro): Generate documents in bulk.