The configuration of your Document Action template can include merging related list fields from child object(s) down two levels. This allows configuration of your template to show related list fields of a child object, as well as related list fields of a child object’s child object.
- Build your Template
- Select your Base and Child Object(s)
- Apply Filters and Sorting
- Add your Related List Field(s) to the Table
Build your Template
- Create the Document Action and custom button following the Basic Configuration Getting Started article.
- Customize the Google Document. Add any text and images directly into the document that you want to be consistent elements within the template (Figure 1).
- Insert a table into the Google Document. Click Insert>Table. Select the number of rows and columns you want for your table (Figure 2).
- Format the table properties. You can edit the table border, color, dimensions, and other properties to suit your preferences. For example, if you don’t want your table to look like a table, you can make the border of your table invisible by changing the table border to “0 point” in Table Properties. To modify the table border, right click “Table Properties” within a table cell, then under “Table border” you can change the border point to “0”. You could also change the color of the border or modify width/table cell height (Figure 3).
- Add related lists. Click the Edit Template button on the top right corner of the Document Action screen. This will take you to Template Builder, where you can add Salesforce merge field code to your Google Docs template. The following sections cover the steps to add related lists to your table.
Select your Base and Child Object(s)
- Select your base object. When you select the base object, a menu of related lists will appear as well as a menu of all child objects with their related lists.
- Select the child object. Choose the child object and related lists to add to your template. For example, to create an Opportunity Summary that shows Opportunity Line Items, you would select Opportunity as the base object and Line Items as the child object. Related lists could include Opportunity Line Item Name, Quantity, List Price, and Total Price (Figure 1).
- Select the child object’s related object. If you would like to go down an additional level, select the child object’s related object from the menu that appears. Choose the related lists you wish to merge. For example, to create a Quote that shows Groups with Line Items, you would select Quote as the base object, Line Item Groups as the child object, and Line Items as the child object’s related object (Figure 2).
Note: If you want to merge a related list from an object that is not on the list of child objects, you would need to relate that object to the object being used as base object of the Document Action.
Apply Filters and Sorting
- Select the related field you wish to merge from the list of related fields that appear when you select your child object or child object’s related object. If you do not wish to apply Filters or Sorting, continue to the next section.
- Apply Filters. You can set a Filter option for the entire table by adding it once to any of the fields you’re merging into the table. Specifically, you may want to filter on some of your related list items based on some condition or validation. For example, you may only want to merge Line Items from a specific group:
- Select the base object and child object, Quote and Line Item Groups.
- Select the child object’s related object, Line Items.
- Choose the related list, Product Name
- In the Apply Filter section, select the field you wish to filter by. In this case, select Group Name, then add your filter into the text box. In this case, if the filter is “Software”, only Line Items within the “Software” group will populate.
- The merge field code will appear in the Merge Field Code section (Figure 1).
- Apply Sorting. If you would like to sort your related list items in a certain order, you can use the Sort By feature. For example, you could sort by the Sort Order field, which is configured on the Opportunity record in Salesforce:
- Select the base and child objects, Opportunity and Opportunity Line Items.
- Choose the related list field, Opportunity Product Name.
- In the Sort By section, select Sort Order and A to Z for ascending order.
- Merge field code will populate in the Merge Field Code section (Figure 2).
Note: If you want to be able to sum up child records in Salesforce, you can use Rollup summary field for Master-Detail relationship Objects and can refer to this FAQ article for more detail.
Add Your Related List Field(s) to the Table
- Add the related list merge field code to one row of your table. Copy the merge field from the Merge Field Code text box and paste it into one row of the table you have created. The row will then repeat for each record (Figure 1, Figure 2). The related lists must be represented within a table so the rows can repeat with multiple values.
- Check the table layout. In order for the related list of the related list to populate, it must be added to a row directly below the merge code of the child object. If you add a row with text or otherwise separate the rows, the related list of the child object’s related object will not populate. Format the table such that the merge field code from the child object is in a row directly above the row containing merge field code from the child object’s related object (Figure 3, Figure 4).