Back to the blog

Automate contract delivery and signature when Opportunity closes

Automation 7 min read 28 September 2026

The problem, quickly

You still ask reps to download a Word file, fill it in, attach it to an email and chase signatures. That process breaks at every hand-off: wrong fields copied, page numbers shift, attachments go to personal inboxes, and signed copies never reach the Contract or Opportunity record.

If you're an admin managing Opportunity, Quote and Contract workflows you need a repeatable click-based way to produce Word or PDF templates from Salesforce data and get them signed — without asking devs for a custom integration.

Why this shows up in Salesforce orgs

Sales teams work from Opportunity and Quote. Legal and finance expect final copies on the Contract record. Those are different objects: Opportunity, Quote, Contract, Account, Contact. When a process requires exporting data, editing in Word, and re-uploading, errors creep in and approval loops lengthen.

A concrete scenario

Imagine 200 renewals a month. Each renewal needs a 60-page contract assembled from Opportunity, associated QuoteLineItems, Account and Contact records, plus a signed page from the customer. Reps spend time assembling the document and chasing signatures. A stage change in Opportunity should trigger the whole thing — but currently it doesn't.

Three click-based ways to automate Salesforce document generation and signature

1) Button-triggered: simplest, user-initiated

Add a button to Opportunity, Quote or Contract that runs a DocuGen action. The rep clicks, picks the correct Word template, confirms signers and storage (Salesforce Files or Notes & Attachments), and sends. This is ideal when you want a human check before sending — e.g., to attach a final pricing addendum or to select an optional clause.

  • Good for one-off or exception sends.
  • No code: button calls the authorised DocuGen connection.
  • Uses anchor tags in the template, so signature boxes survive repagination.

2) Record-triggered Flow: automate on stage or field change

Use a Record-Triggered Flow on Opportunity stage = "Closed Won", or a Contract.Status = "Pending Signature". The Flow finds related Quotes and Contact signers, then calls the DocuGen action to fill templates and send for signature. Everything runs from clicks in Flow Builder — no managed package to install.

Why this works for admins: templates are Word or PDF, signer email and password can come from Contact or a custom Signer__c record, and the completed, signed PDF is written back to the same record automatically.

3) File or field-change trigger: start from uploads or approvals

You can trigger DocuGen when a file is uploaded or when a checkbox flips (approved_by_legal__c). That makes it easy to build handoffs: legal uploads an approved clause package and the contract automatically assembles, bundles multiple templates if needed, then sends the whole bundle for signature.

Admin design tips: templates, storage and signer identity

Templates and anchor tags

Author your templates in Word. Use anchor tags for signatures (like \[sign:Customer\]) — they survive repagination so you don't have to hard-code page numbers. If you need line-item rows, DocuGen pulls child records as repeating table rows (QuoteLineItem, custom line items on custom objects__c). It also supports up to five levels of parent lookups when you need Account -> Parent Account -> Region data.

Where to store completed docs

Decide up front: Salesforce Files or Notes & Attachments. DocuGen writes the finished document back to the record. Documents up to 40 MB are supported; remember Notes & Attachments is capped at 25 MB by Salesforce. If your bundle includes large attachments, use Files.

Signer identity and security

DocuGen sends via your organisation's Circularo account and supports signer verification: you can require an emailed one-time code, and read a per-signer password from that signer's Salesforce record. That lets legal insist on a second authentication without changing how reps start the send.

Example Flow outline (what you'll click in Flow Builder)

// Record-Triggered Flow: Opportunity, when Stage = Closed Won
1) Trigger: Opportunity record change
2) Get Records: Account (Opportunity.AccountId)
3) Get Records: Quote WHERE OpportunityId = {!$Record.Id} ORDER BY LastModifiedDate DESC LIMIT 1
4) Get Records: Contacts WHERE AccountId = {!Account.Id} AND IsPrimary__c = true
5) Action: DocuGen - Fill Template and Send
   - TemplateId: 'Renewal_Contract_Template'
   - MergeSource: Opportunity + Quote + QuoteLineItems
   - Signers: {!Contacts.Email} mapped to anchor tags
   - Storage: Files on Opportunity
6) Update Records: Opportunity.Contract_Sent__c = true

This is click-configurable. The DocuGen action in Flow accepts the template, signer mapping, bundle options and storage target as parameters.

After it's live: what changes and what to watch

When done correctly, the signed PDF lands on the Opportunity or Contract record without manual uploads. Because signature positions use anchor tags, templates don't break when clauses move between pages. Bundles let you combine a 60-page contract and a short SOW into one signature run so customers sign everything at once.

Monitor the first few dozen runs: check that the right QuoteLineItems appear, that the signer emails are correct, and that storage goes to Files when documents are large. Adjust templates rather than code; Word template edits are the fastest fix.

Why this is manageable for admins

You don't need to install a managed package or open a DevOps ticket. DocuGen connects through an authorised connection and works the same in sandboxes as production, so you can build and test your Flows and buttons without touching live data. That keeps your change window small and reduces risk.

Savvy DocuGen fills Word and PDF templates from any Salesforce record, bundles templates into one signature run, uses anchor tags for stable signature placement, supports signer verification, and writes the signed PDF back to the same record. Try it in your sandbox: wire a Record-Triggered Flow on Opportunity, add a template with anchor tags, and send a test bundle for signature.

Try Savvy DocuGen in your sandbox today — add a button or build a Flow and send a test contract from an Opportunity.

Read next