Feature Overview

S-Docs Render is a powerful feature that permits sections (or blocks) of text and data to display in your generated document only when a condition is met. This provides a mechanism to create a single template that can dynamically show and hide portions of the document based on conditional logic.

While you can also achieve simple dynamic rendering within your S-Docs templates by only using Salesforce formula fields (without the S-Docs Render feature), this approach has limitations and can be difficult to scale.

To address these limitations, S-Docs provides two levels of Rendering: Basic Render and Advanced Render.

The Basic Render feature can be used to show or hide a block of your S-Docs template based on a single condition. We suggest this approach first because it is simple and can meet most requirements.

For more complex requirements where advanced logic is needed, the S-Docs Advanced Render feature can be leveraged. The Advanced Render feature uses Salesforce APEX syntax to evaluate complex and compound logical statements.

Conditional Logic With Salesforce Formula Fields

You can achieve simple rendering using only Salesforce formula fields. This technique works by using a formula field which returns either text or a blank value based on the conditional logic you set in the formula. That formula field is then simply merged into your S-Docs template just like any other merged field. While this is simple, you may reach the upper size limits of the formula field if you want to show large blocks of text.

For example, dynamically inserting "Terms and Conditions" in your document based on another field value should not be done with a formula field. Moreover, having text and logic split between your template and formula is not a good practice, as this becomes difficult to maintain.

Lastly, if you have many conditions in multiple S-Docs templates, this approach is not practical because it will require too many formula fields to be created. We therefore suggest this approach for only the simplest cases, or where the formula field already exists for other purposes. For example, if you already have a field called "Delivery Charge" and you want it to display "No Charge" for "Gold" tier customers, you may use a formula field like the one below:

Conditional Logic With The S-Docs Render Feature: Basic Usage

The S-Docs Render feature provides a mechanism to dynamically show or hide information without having to create additional templates for every use case. You add a render statement into your S-Docs template, and if it evaluates to TRUE, then the entire block (up to the closing ENDRENDER tag) is included; otherwise it is omitted. To use the S-Docs Render feature, you can insert the syntax yourself, or click the Insert RENDER button. This document will focus on editing render syntax yourself.

We'll begin with an example. You may want to display an additional paragraph in your document if the client lives in California. Here is a snippet that you would add to your S-Docs template where you want the text to appear:

The basic S-Docs render feature supports eight basic comparators (==, !=,  >, <, >=, <=, CONTAINS and NOT CONTAINS).

Note: If any fields in your render statement contain words and have a field type anything other than a basic string type (rich text, textarea, longtext, function, etc.) you will need to add the  merge field attribute render. For example, if your merge field looked like this: {{!MyTestField}}
The field with the attribute added would look like this: {{!MyTestField render}} Within a render statement, it would look like this:
<!--RENDER= {{!MyTestField render}} == Test -->{{!Opportunity.closedate M/d/yyyy}}<!--ENDRENDER-->
Note that this attribute should only be added to merge fields within render tags (e.g. enclosed by <!-- and -->). In the above example, the attribute  is not added to the {{!Opportunity.closedate M/d/yyyy}} because this merge field is outside of the render tags.
Additionally, note that the Insert RENDER button will not add this attribute automatically. This functionality was added in version 4.48

Render is also useful to determine if a value is empty or NULL. In the example below, we can create two render blocks. Since the value can only be null or NOT null, we are assured that only one of the render blocks below will be included in the final document output:

Basic Render and Nested Render Statements

S-Docs provides for 4 levels of nesting render statements. This allows you to place conditions within other conditions. Using nested render statements can also be leveraged to achieve compound logic as shown in the example below:

There is no limit on the number of render statements you place within other render statements, however you are limited to nesting them to a maximum of 4 levels deep. Note in the example above that you can have multiple "Render1" tags within the same parent "Render" tag. However, you must change the render tag name whenever you are nesting a render within another render statement. When doing this, you must change the name of the nested render tag to "RENDER1" "RENDER2" or "RENDER3" and this name must be different than any of its parent tags.

You must also be certain that all render statements are properly terminated (with an ENDRENDER tag) so that they do not intersect (overlap) with another render tag with the same name.

Important Note: Whenever using the S-Docs Render feature, all of your RENDER and ENDRENDER tags must be properly paired and terminated.

Basic Render Without Nesting

S-Docs also uses AND (&&) and OR (||)  in the RENDER statement, so you don't have to nest. A RENDER statement using AND (&&) can be leveraged to achieve logic as shown in the example below:
Similarly, OR (||) can be used as shown in the example below:

AND (&&) and OR (||) can be used concatenate multiple statements. For example:
A similar method using the Runtime Prompt can also show a prompt by letting the user choose to include or to not include the block of text.

'CONTAINS' and 'NOT CONTAINS' Statements

In addition to checking for a string of quality with boolean functions, you can use 'CONTAINS' or 'NOT CONTAINS' to look for a specific string of quality. For example, a statement with 'CONTAINS' would look like:

And a statement with 'NOT CONTAINS' would look like: