Solution. Organizations often have multiple templates containing identical sections. For example, you might have to include a terms and conditions section in several different templates. The most straightforward way of accomplishing this is simply copying the section and pasting it into all of your templates. Of course, this is not a maintainable solution; if you put the section in 10 different templates, every time you make an edit, you’ll have to edit 10 different templates!

If you need to consolidate a component that is used in a variety of templates, consider the following solution: create a template for this component, and simply include that template as {{{{!YourTemplateNameHere}}}} wherever you need it in your other templates.

With this solution, we can easily insert a template into as many templates as we’d like, and only have to edit one template if we need to edit the inserted section. Additionally, we wouldn’t have to worry about the complicating the structure of the template where our insertion template is used; we can insert an incredibly complex template into another in just one line.

Note. This solution is for appending templates that do not include Salesforce data. Hence, the child template (i.e. the template that you are inserting as a merge field) should not include any merge fields, related lists, SOQL queries, etc., as these will not be displayed in the final document. On the other hand, the parent template can still include merge fields, related lists, SOQL queries, etc., as shown in the following example. The same holds for CSS in the child template. Please refer to the end of this document for workarounds.

Now, let’s see how we can use the same terms and conditions section across several different templates. First, we create a template called “Terms and Conditions”. In our example use case, we won’t ever need to generate the terms and conditions by itself, so we uncheck the boxes “Available for Use” and “Initially Visible”. Now this template won’t show up when users are prompted to generate an S-Doc, and this template will never be generated by itself.

Insert Template Within a Template (1)

Here is the template body for our terms and conditions template:

Insert Template Within a Template (2)

We will be inserting this template into the following template for an invoice.

Insert Template Within a Template (3)

Note that the terms and conditions template has different “Related to Type” and “Template Format” fields than the invoice template. When we generate the invoice template, we’ll be generating a PDF for an opportunity, not a DOC for a contract. The “Related to Type” and “Template Format” fields of the terms and condition template are irrelevant; they have no effect, and this template can be inserted into any other template regardless of the values of these fields. This is also true for all the other fields (such as “Auto Create Attachment”) on our template record; the Invoice’s fields will be used, and the terms and conditions fields will be ignored. Thus, we can choose arbitrary fields for our terms and conditions template and insert this template into any other kind of template.

All we need to do now is open the template editor for the invoice template and insert the following field:

{{{{!Terms and Conditions}}}}

Insert Template Within a Template (4)

Now, when we generate an invoice PDF for an opportunity, the result will include our terms and conditions inserted right where we had specified:

Insert Template Within a Template (5)

We could’ve inserted this anywhere in the template; we could even insert it between the “INVOICE 3-2-1” header and the related list by inserting the {{{{!Terms and Conditions}}}} field in that location. Of course, in this example, it makes more sense to put it at the very bottom.

Now, if we had other templates we wanted to insert the terms and conditions into, we could insert the {{{{!Terms and Conditions}}}} field into those templates as well.

Setting the Template Format to "Component"

Any S-Docs Template can be included in another template as a component, regardless of template format. However, if you plan on using a template solely as a component (i.e. it will never be used to generate a document by itself), you can set the S-Docs Template Template Format field to "Component". As a result, the end user will not be able to select this template by itself to generate documents. Additionally, for any other S-Docs Template that has the same Related To Type as a template whose Template Format field is set to "Component", that component template will be available for insertion as a merge field in the "Other Templates" tab in the "Insert Merge Field" window in the template editor. (note: some versions of S-Docs do not have "Component" as an allowed value in the Template Format picklist; nonetheless, you can add "Component" to the set of picklist values yourself by going to Setup > Create > Objects > SDoc Template > Template Format > Values  > New).