Back to the blog

Salesforce document generation: repeating tables from Opportunity products

Document Generation 7 min read 17 November 2026

Problem: your quotes need line-item tables but copy-paste is killing you

You're an admin who keeps getting requests: “We need a proposal that pulls Opportunity fields and lists all products with quantity, price and discount—automatically.” Right now someone copies from a report into Word, fiddles the layout, emails it, then waits days for signature. That's manual work, mistakes and versioning mess on Account and Opportunity records.

Salesforce document generation: what you must plan for

Before you open Word, think about three things that break projects like this: data shape, document structure and storage. Do you have the right fields on Opportunity and OpportunityLineItem? Does the document need parent lookups (Account, Contract) or child objects (custom services __c)? Where should the finished file live—Files or Notes & Attachments?

  • Data shape: confirm API names and relationship names on Opportunity, OpportunityLineItem and any lookup parents up to five levels.
  • Document structure: design a table row in Word that can repeat for each product line.
  • Storage and signature: decide whether the document must be signed (Circularo) and whether it will be stored as Salesforce Files (use for >25 MB or preferred behavior) or Notes & Attachments (25 MB cap).

Salesforce document generation: step-by-step for admins

Follow these steps in your sandbox. I assume you have the Savvy DocuGen connector authorised in the org and you can upload templates.

1. Prepare your data on Opportunity and line items

  • Confirm the Opportunity fields you need: StageName, CloseDate, Amount, Opportunity.OwnerId, any custom fields like Contract_Term__c.
  • Check OpportunityLineItem fields: Quantity, UnitPrice, TotalPrice (or a custom formula for discounted price), Product2.Name. If you store discounts on a custom child object, note that too.
  • Fix data quality: if some products miss descriptions or prices, clean them now—those gaps become blank rows in the document.

2. Build the Word template table row (clicks, not code)

Create a table in Word with one row for headers and one row for the repeating data. In that data row place placeholders for each column—product name, description, qty, unit price, line total. The connector reads the row as a template and repeats it for each child record.

Header row: Product | Description | Qty | Unit Price | Line Total
Data row: {{Product2.Name}} | {{Description}} | {{Quantity}} | {{UnitPrice}} | {{LineTotal}}

Notes: use plain text placeholders that make sense for your team. The connector reaches child records and will repeat the row for all OpportunityLineItem rows related to the Opportunity.

3. Upload and map the template

  • Upload the Word template in the DocuGen template manager and choose Opportunity as the primary object.
  • Map the table to the OpportunityLineItem relationship (or your custom child object) so the connector knows which child rows to repeat.
  • If you need parent lookups—Account billing address, Contract number—map those fields too; the connector supports up to five levels of parent lookups.

4. Configure output, storage and signature options

  • Decide where the finished document files: Salesforce Files is safer (and required for documents larger than 25 MB). Notes & Attachments caps at 25 MB.
  • If you need signatures, configure signature via your Circularo account. Anchor tags in the Word template let signature blocks survive repagination.
  • If multiple templates must be merged into one signed bundle (proposal + T&C), use the bundle option so recipients sign a single PDF.

5. Choose a trigger—manual or automated

For admins who want clicks: you can add a button on the Opportunity page layout that runs the merge when a user clicks. For automation: configure the DocuGen template to run when an Opportunity stage changes, when a field changes, or when a new file is uploaded. That means you can generate the SOW when StageName becomes “Contract Sent” without building code.

Concrete scenario: a 12-page SOW with 40 line items and 200 renewals a month

Imagine a 12-page statement of work that pulls Opportunity details, Account billing contacts and 40 product rows from OpportunityLineItem. You run the merge automatically when StageName changes to Contract Sent. The template creates the document, files it to the Opportunity as a Salesforce File, then bundles it and sends for signature via Circularo. For recurring renewals you can trigger the same template on a custom Renewal record—no manual edits.

This handles the usual admin headaches: no multi-tab copy-paste, single version of the truth on the Opportunity, and signature anchor tags that keep signers’ boxes in place even if the table grows and repaginates the document.

Common pitfalls and how to avoid them

  • Missing child rows: if your template returns no product rows, check the relationship name and whether the child records are saved with the OpportunityId filled.
  • Wrong values in the table: confirm you used the right API field names or mapping in the template manager, and that formula fields are visible to the running user.
  • Storage surprises: large documents go to Files. If you try Notes & Attachments and hit the 25 MB limit, the merge will fail—plan Files for bigger content.

You can set this up in a sandbox and it behaves the same as production. Savvy DocuGen fills Word and PDF templates from any Salesforce object, handles child records as repeating table rows, reaches five levels of parent lookups, files the finished document on the record, and can send it for signature through your Circularo account with anchor-based positions that survive repagination.

Try this in a sandbox: create a simple Opportunity with several OpportunityLineItem rows, upload a Word template with a table row for products, and test a button or stage-change trigger. If you want help mapping a particularly tricky table layout, try it in your sandbox and reach out—start there.

Read next