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 terms and conditions 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 a merge field similar to {{{{!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 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.

Create A Component Template

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,” and set the Template Format to "Component." Templates with a Template Format of "Component" will not show up as available templates when users are generating documents, because they cannot be generated by themselves -- instead, they'll be available to insert into other templates when you click the Insert Field button, under the Other Templates tab.

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 navigating to Setup > Object Manager > SDoc Template > Fields & Relationships > Template Format > Values  > New.

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

Note: Component templates support <nullprefix>, <nullpostfix>, <allprefix>, and <allpostfix> tags.

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

Note that the invoice template has different “Related to Type” and “Template Format” fields than the component template. 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 of the other fields on our component 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.

Open the template editor for the invoice template, place the cursor where you'd like your terms and conditions to appear, and click Insert Field.

Navigate to the Other Templates tab, select the name of the terms and conditions template, and click Insert to insert the component as a merge field where your cursor was, or click Copy to Clipboard to copy the component merge field syntax and manually paste it into the template.

Note: Any template with a Template Format set to "Component" will show up in this list, regardless of its Related To Type object, as long as the Available for Use and Initially Visible checkboxes are checked for the component.

As you can see, the component merge field was added to our document.

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

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.

If we wanted to include the terms and conditions in other templates, we could insert the {{{{!Terms and Conditions}}}} field into those templates as well.

Using Template Formats Other Than "Component"

Any S-Docs Template can be included in another template as a component, regardless of template format. However, templates with a Template Format other than "Component" will not be available in the Other Templates tab within the Insert Field menu; you will have to write the merge field syntax for those templates manually.

In addition, templates that don't have a Template Format of "Component" will show up to users as standalone documents that can be generated by themselves, unless you uncheck the Available for Use and Initially Visible checkboxes.