Use The "Insert Related List" Button

Child or related records will appear as line items in a table within your document. Since there can be zero or more child records associated to a parent record, it would not be feasible to map a child field to just one parent field. Therefore, S-Docs renders child records as rows in a table. You can control the columns displayed, or add multiple child tables to one document. The simplest way to add a related list is to use the Insert Related List button on the template editor page (for instructions on how to use this button, click here). Using this feature will allow you to easily select the related objects and columns. If needed, you can then edit the table header and styles using the template editor.

Edit The Source Code of Your Related List Table

For even greater control, you can also edit the template source code. Editing the template source will give you total control of styles and will permit you to drill down into one extra level of relationships if needed. Therefore, you can reach fields up to 4 levels removed from the base object. If fields are still further than this, consider using a formula field to make the value available to your document.

If you edit the template source for custom objects, be sure to use the correct “child relationship name” in between the ListName tags (e.g. <ListName>myRelatedObject__r</ListName>). This name does not always match the object name, as Salesforce can automatically change this value to avoid collisions, so be sure to verify this value from the custom field definition page within Salesforce.

Example: Template Source for Opportunity Line Items

In the template editor, click on the Source button, and then place the following snippet into a <table> element. You should create the first header row with column header values. Then place the LineItems tag as shown below as you would normally use a <tr> element.  When rendered, this code will be represented as a table rows <tr> within the table, and include the related list field values that you specified for columns.

The following snippet will render as a <tr> element. It should therefore be placed within your <table> element:

Be sure to include the HTML comment tags (<!-- and -->) exactly as shown in the snippet above. While the line items won’t appear on the template editors WYSIWYG view, they will render when the document is generated.

Note: Since S-Docs is a Native app, it is subject to Salesforce’s governor limits. The complexity of your objects will determine the maximum number of related lists and the maximum number of line items that you can include in your document before reaching these limits. We are continually working on improving this limit. For more information visit