Skip to content Skip to main navigation Skip to footer

Template Configuration

Once you have followed the Basic Configuration article to create your Document Action, it is time to configure your Document Action template by following the steps below.

  1. Open the Template Builder
  2. Select Base and Child Object(s)
  3. Apply Filters and Sorting
  4. Merge TODAY() Date
  5. Merge URL with Label
  6. Merge HTML or Rich Text Fields
  7. Merge Images
  8. Bulk Image Merge
  9. Add Conditional Section Merge
  10. Merge Field or Related List Into Document
  11. Conditional Section Merge within a Table

Open the Template Builder

From the Document Action record, click the “Template Builder” tab on the top left corner of the Document Action screen (Next to “Details” tab). This will take you to the Template Builder, where you can add Salesforce merge field code to your Google Docs template.

Select Base and Child Object(s)

Object Fields

Use this menu to merge fields from the base object and related objects.

Click the arrow to the left of the “Object Fields” header. The base object appears in blue and below that a list of all base object fields as well as lookups to related objects. All lookup fields have “ID>” following the field label. Click on the lookup field and a menu of fields from that object will appear. When you select a field, the merge code will populate in the “Merge Field Code” bar below.

Child Objects

Use this menu to merge fields from the child object and child object’s related objects.

Click the arrow to the left of the “Child Objects” header. A list of all child objects appears. Click the child object to see a list of all child object fields as well as lookups to related objects. All lookup fields have “ID>” following the field label. Click on the lookup field and a menu of fields from that object will appear. When you select a field, the merge code will populate in the “Merge Field Code” bar below.

For example, to create an Opportunity Summary that shows Opportunity Line Items, you would select Opportunity as the base object and Opportunity Line Items as the child object. Example related lists could include Opportunity Product Name, Quantity, List Price, and Total Price.

As a second 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.

Once you’ve selected the related lists, continue to next section for information about filters and sorting or skip directly to Merge Field into Document.

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

Apply a Filter

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, to merge Line Items from a specific group:

  1. Select the base object and child object, Quote and Line Item Groups.
  2. Select the child object’s related object, Line Items.
  3. Choose the related list, Product Name
  4. 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.
  5. The merge field code will appear in the Merge Field Code section for you to copy/paste into the document.

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:

  1. Select the base and child objects, Opportunity and Opportunity Line Items.
  2. Choose the related list field, Opportunity Product Name.
  3. In the Sort By section, select Sort Order and A to Z for ascending order.
  4. Merge field code will populate in the Merge Field Code section for you to copy/paste into the document.

Notes:

  • If you would like to filter based on more than one filter condition, create a formula field that results in a checkbox and put all the different logic in if statements into that formula field. Then, you can filter on the single formula/checkbox field. The formula can have all the different conditions.
  • 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.

Merge TODAY() Date

To merge the current date (at the time of document generation), select the “Today Date“ checkbox on the document action template. Copy/Paste the merge field code into your document. The merge field should look like this: {!{TODAY}}. Merged date will be in MM/DD/YYYY format.

Merge URL with Label

Select the field in the Template Builder that contains the link. Select checkbox, “Link”. In the field to the right of the checkbox, either enter hardcoded text or select a merge field for the URL label . Copy/Paste merge field code into the template.

Merge HTML or Rich Text Fields

Opero Documents supports basic HTML or rich text fields for document generation (list, bold, italic, color, underline, font size). Users can merge HTML or rich text fields from the base or child object. Merge fields into a table or directly into the body of the document. Filters are supported. For specific considerations and guidance merging rich text fields, please see our knowledge base article: Merging Rich Text Fields Considerations.

Formatting & Configuration Guidelines:

  • If a field is rich text, the merge field should have “[HTML]” suffix, e.g., {!Opportunity.Rich_Text_Field__c[HTML]}. When using the Template Builder to add rich text fields into your template, the [HTML] suffix will be added dynamically.
  • Place each rich text merge field on its own line.
  • To merge from a child object into the body of the document: place the rich text merge field into a table. After the field is merged into the document the table will be removed. If you are merging rich text field from a child object into a table, place the merge field directly into the table.

Merge Images

Opero Documents allows you to dynamically merge images from a public URL accessible to the internet. Supported image types include jpg, jpeg, png, gif. To merge the image into your document, you’ll create a custom long text field, add the publicly available URL to the custom field, then merge the custom field into your template. See detailed steps below:

Create a custom field 

This custom field will hold the URL and add to base object’s page layout. Field type should be “long text” rather than URL, since the URL Sources in this article will have URLs that exceed the 255 character limit.

Choose your URL source

Follow the steps below to create a publicly available URL to the direct image.

Documents (Classic only)

  • Go to Documents tab in Salesforce.
  • Upload the image to Documents or open an existing Documents file.
  • Select the checkbox “Externally Available Image”.
  • Right click the image and select “Copy Image Address”.
  • Paste URL into the custom long text field.

Files (Lightning only)

  • Upload a new file or open an existing one
  • click “public link” option at the top of the window
  • Expiration Date and Password toggle should be OFF
  • click “Create Public Link” button
  • Copy that link and open it in a new tab.
  • Right click on the image displayed.
  • Select “Copy Image Address”.
  • Paste URL into the custom long text field.

Web Source

You can merge images from a publicly available web source, images hosted on any web server, AWS, or CDN server.  To copy the direct URL of the image, right click the image and select “Copy Image Address” and paste the URL into the custom long text field.

Google Drive

If you would like to merge images that are stored on Google Drive, this is possible; however, the link provided by Google does not work as provided so some modification is necessary (see below for each option). In general, we have found that using publicly available images from Google Drive is not as reliable as the other options; we would advise using Files, Documents, or web source instead if possible.

Google Drive – Public Folder

  • Put your files in a public folder.
  • Right click “Share” button at top right of screen.
  • Change settings to “Anyone with Link”=”Viewer”.
  • Any file in the folder will be made publicly available by entering URL in this format: “https://googledrive.com/host/<folderID>/<filename>”.
  • For example, if you created a test folder on Google Drive and uploaded a file testImage.png, the image URL would be: “https://googledrive.com/host/0BwdB0jiqM9yCXzlGeDZjaUhYZFk/testImage.png”.
  • Copy the new image URL and paste it into the custom long text field.

Google Drive – Main Folder

If you don’t want to put files into a shared folder, you can use images that are uploaded directly to Google Drive (as long as they’re publicly accessible).

  • The image URL format will be: “https://docs.google.com/uc?id=<file-ID>”.
  • For example: If you uploaded a file directly to your drive with a file ID of “0BwdB0jiqM9yCM01iekxpdlc4ZHc“, the Image URL would be:  “https://docs.google.com/uc?id=0BwdB0jiqM9yCM01iekxpdlc4ZHc“.
  • Copy the new image URL and paste it into the custom long text field.

Merge the Image Field Into Your Template

  1. Locate the custom field in the template builder.
  2. Check the “Image” checkbox.
  3. The merge field code will populate in the “Merge Field Code” field at the bottom for you to copy and paste into the template body, header, or footer.

Bulk Image Merge

If merging three or more images into your template, we recommend selecting the Bulk Merge Images checkbox on the Document Action. When enabled, this feature uses Google Docs Batch API to merge images, which works faster for a larger number of images. When using this feature, it is not possible to set the width of the image to depend on the table cell width. As a result, it will be necessary to prepare images in the actual size that will need to be merged into the document. Customers upgrading the app from older versions will need to add this field to the Document Action object page payout.

Add Conditional Section Merge

The conditional section merge feature allows you to merge one or more sections into your document based on a condition of a checkbox or formula field. It is also possible to have one checkbox field that refers to multiple conditional merge sections in template. The section merge feature also makes it possible to create a conditional page break in your template.

Conditional Merge Based on a Checkbox Field

The conditional merge feature allows you to merge sections of text or entire tables into your document based on the value of a standard checkbox field (true or false). There will be a start and end to each conditional merge section that you will need to mark with tags. The template builder will generate the tags for you as part of your merge field code that you copy and paste into the document. Your conditional merge section start and end tags should be on their own line in the template.

After the merging of start/end conditional section is completed within the generated document, these tag lines will be removed from the document. Note that if you have a conditional merge section end tag at the end of the document template, you must add one extra line below that tag so the conditional end section end tag is not the last line of the entire document.

As an example, a sales rep could use the conditional merge feature to control whether to include or not include a “Special Terms” section in a contract document attached to an Opportunity record. To do this, they would create a checkbox field on the Opportunity object called “Special Terms”. If on the Opportunity record this checkbox field were checked (true), then this additional agreement section would merge onto the template. If this checkbox field were not checked (false), then this agreement section would not merge onto the document.

Steps to configure:

  1. Select the related checkbox field from in embedded template builder. For this example, we are using “Special Terms”.
  2. Under “Section”, type the section name, then select “Start of Section” and it will generate the merge field code for your conditional section start.
  3. Copy this merge field code and paste it where you want the section to start on your template.
  4. Repeat these steps to generate the conditional section end tags and paste where you want the conditional section to end.
  5. Add the conditional section to the document  between the start and end tags. This conditional section can contain any combination of hardcoded text or merge field code. This content will only display if the checkbox = TRUE.

Conditional Page Break

You can create a page break within the conditional section merge. This can be helpful to control where the page break will occur if the conditional section is merged. For example, to ensure that the conditional section is preceded by a page break, you’d arrange the template as follows:

[Merge field code for your conditional section start]

<<add page break>>

Text of your conditional section goes here.

[Merge field code for your conditional section end]

For example:

Example generated document with conditional page break

This conditional page break ensures that, if the conditional section merge occurs, there will be a page break prior to the text within that conditional section. Note that conditional sections are not currently supported in related lists.

Conditional Merge Based on Formula Field

If you would like to merge conditionally without using a checkbox field, you could create a checkbox type formula field and build that formula logic based on any field available to result in a true or false value. It is also possible to conditionally merge based on values from a picklist by creating a formula field with the type “checkbox” and reference the picklist values to create the True/False value of the checkbox in that formula field.

For example:

Create a conditional merge section based on a formula field on an Opportunity record to merge ONLY if there is at least one product related to the Opportunity.

  1. Create the section and content on template builder.
  2. Create a custom checkbox formula field on the base object, e.g. Opportunity. The formula field in our use case could be called “Line Items Exist”. This formula would have an IF statement to check whether the record has at least one product related to the Opportunity, then return true or false.
  3. Go to the template builder and select the formula field.
  4. Check the box to indicate that it is a conditional section.
  5. Copy/paste the merge field code to create the section start/end tags in your document.

Multiple Conditional Section Merge

If you would like to have one checkbox field that refers to multiple conditional merge sections in a template, see this use case article for more detail: Checkbox Field that Refers to Multiple Conditional Merge Sections Within a Template

Merge Field or Related List Into Document

To merge a field, copy the value from the “Merge Field Code” and paste it into the body, header, or footer of the template.

To merge a related list, copy the value from the “Merge Field Code” and paste the merge field code into one row of a table. The row will repeat for each record. The merge field code must be represented within a table so that the rows can repeat with multiple values.

Example table with merge fields from a related list.

To merge a related list from a child object’s related object, 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.

Example table with merge fields from a child object’s related object.
Example generated document with merged fields from a child object’s related object.

Conditional Section Merge Within a Table

Opero Documents supports conditional section merge within a table. For example, this template conditionally merges child object fields based on the value of a custom checkbox “Show__c”. The base object is Account and it is merging information about related opportunities where the “Show” checkbox equals true.

Google Doc Template
Generated Document