How to Apply Merge Tags for Child Records (Multiple Records)

Updated March 26, 2026


1. Step 1: Log In to Salesforce

  1. Navigate to the Salesforce login page

  2. Enter your Username and Password.

  3. Click Log In (Submit).

Step 2: Open the Doc-Gen Application

  1. Click the App Launcher (nine-dot icon in the top-left corner).
  2. In the search bar, type Doc-Gen.
  3. Select Doc-Gen from the results.

Step screenshot/>

2. # Step 3: Select Fields from Merge Fields

Step 3.1: Select the Main Object

  1. Click Merge Field Tab.

  2. Select the main object that will generate the document.

Example used in this demo:

  1. Click Billing

This defines the main object for the document.

Step 3.2: Select a Field from the Main Source Object

  1. Click Billing Name (Name)

This field will be inserted into the document template.

Example merge key copied:

LawAccounting__Billing__c.Name




















Step 3.3: Insert the Merge Tag into Word

  1. Open Microsoft Word

  2. Place the cursor where the field should appear

  3. Click Insert

  4. Click Text

  5. Click Field

  6. Select MergeField in Field name

  7. Paste the merge key copied

Example:

LawAccounting__Billing__c.Name




















  1. Click Save

Step 3.4: Select a Field from the same Parent Object (Billing)

  1. Click Customer (Account) underneath Parent Objects

  2. Click Party Name (Name) underneath Object Fields when you get redirected.

Example merge key copied:

LawAccounting__Billing__c.LawAccounting__Customer__r.Name




















Step 3.5: Insert the Parent Merge Tag

  1. Place the cursor in the Word template where the field should appear

  2. Click Insert on Ribbon

  3. Click Text (MacOS) or QuickParts (Windows)

  4. Click Field

  5. Select MergeField in Field name

  6. Paste the merge key copied

Example:

LawAccounting__Billing__c.LawAccounting__Customer__r.Name




















  1. Click Save

Step 3.6: Select a Child Object Field

  1. Click Billing Line
  2. This will navigate you to new page. Click Billing Name (Name) in Object Fields.

Example merge key copied:

LawAccounting__Billing__c.LawAccounting__Billing_Lines__r.Name




















Step 3.7: Insert the Child Object Field

  1. Place the cursor in the Word template

  2. Click Insert

  3. Click Text

  4. Click Field

  5. Select MergeField in Field name

  6. Paste the merge key copied

Example:

LawAccounting__Billing__c.LawAccounting__Billing_Lines__r.Name




















  1. Click Save

Step 3.8: Select Another Child Object Field

  1. Click Billing Line
  2. This will navigate you to new page. Click Total (LawAccounting__Total__c)

Example merge key copied:

LawAccounting__Billing__c.LawAccounting__Billing_Lines__r.LawAccounting__Total__c




















Step 3.9: Insert the Child Object Total Field

  1. Place the cursor in the Word template

  2. Click Insert

  3. Click Text

  4. Click Field

  5. Select MergeField in Field name

  6. Paste the merge key copied

Example:

LawAccounting__Billing__c.LawAccounting__Billing_Lines__r.LawAccounting__Total__c




















  1. Click Save

Step 4: Save the Word Template

  1. Click File

  2. Click Save As

  3. Click Save

Save the document as a .DOCX or PDF template file.

Example used in this demo:

Billing Template2.docx




















Step 5: Create a Template Record in Salesforce

  1. Click Templates

  2. Click New

  3. Click Object Type

  4. Select the object associated with the template

Example used in this demo:

Name: Billing Template2 | Object Type: [[LawAccounting__Billing__c]]

  1. Click Save

Step 6: Upload the Template

  1. Open the created template record and navigate into Related
  2. Click Upload
  3. Select the DOCX template file
  4. Click Done

Step 7: Create a DocGen Solution

  1. Click Doc-Gen Configuration

  2. Click New

  3. Click Solution Name

  4. Enter a name for the solution

Example used in this demo:

Billing Document Solution2



  1. Select the Main Object

Example used:

Billing ([[LawAccounting__Billing__c]] )

  1. Click Select a template

  2. Choose the template created earlier

Example:

Billing Template2

  1. Enter an Output File Name

Example:

Test2



  1. Click Save

Step 8: Generate the Document

  1. Navigate to a record for the selected object

Example used in this demo:

Billing Record

Example record ID:

B-00823



  1. Open the record

  2. Click Generate

The system processes the template and merges record data.

Step 9: Verify the Generated Document

Depending on the configuration, the document may:

• Attach to the record
• Download to the computer
• Open in preview
• Send via email

The fields shown in this guide are examples used only to demonstrate functionality. Your organization may select different objects and fields depending on its configuration.

Step screenshot/>

Back to Knowledge Base