Skip to main content

Create Advanced Conditional Logic

This topic will walk you through how to create advanced conditional logic for Ironclad Clickwrap. This topic is specific to the New Clickwrap Experience.

This topic is specific to the New Clickwrap Experience. If you are using the Classic Clickwrap Experience, refer to the Classic Clickwrap Experience documentation.
​
On occasion, you may need to employ more advanced conditional logic to dynamic templates in order to render the appropriate verbiage under different circumstances.
​
If you want to learn more about conditional logic and view common examples, refer to Create Dynamic Templates.


Use Advanced Conditional Logic

Below are some examples of advanced conditional logic that can be applied to your dynamic templates.
​Note: These are just examples, and there are infinite variations to these scenarios that can be mixed and matched in order to achieve your desired outcome.

Scenario

Helper(s)

Logic Statement

Logic Statement in the Editor

Show verbiage if a token’s value is true or not null; else, show verbiage if a token’s value is false or null.

if else

{{#if token}}This verbiage shows if token is true or not null.{{else}}This verbiage shows if token is false or null.{{/if}}

1.jpeg

Show verbiage if a token has a specific value; else, show verbiage if a token does not have the specific value.

if else, matchesValue

{{#if (matchesValue token ‘value1’)}}This verbiage shows if token has the exact value ‘value1’{{else}}This verbiage shows if token does not have the exact value ‘value1’.{{/if}}

2.jpeg

Show verbiage if a token has a specific value; else, show verbiage if a token has a different specific value; else, show verbiage if a token does not have either of the specific values.

if else, matchesValue

{{#if (matchesValue token ‘value1’)}}This verbiage shows if token has the exact value ‘value1’{{else if (matchesValue token ‘value2’)}}This verbiage shows if token has the exact value ‘value2’{{else}}This verbiage shows if token does not have the exact value ‘value1’ or ‘value2’.{{/if}}

3.jpeg

Format a token’s value to be uppercase

uppercase

{{uppercase token}}

4.jpeg

Format a token’s value to be lowercase

lowercase

{{lowercase token}}

5.jpeg

Show verbiage if a token’s value starts with a specific character

if, startsWith

{{#if (startsWith token 'J')}}This verbiage shows if token starts with 'J'.{{/if}}

6.jpeg

Format a valid date string

formatDate

{{formatDate token “MM/DD/YY”}}

{{formatDate token “MM/DD/YY”}}

Format a numerical token value to have two decimal places

numberFormat

{{numberFormat token 2}}

8.jpeg

Format a numerical token value with a period as the decimal separator (default)

numberFormat

{{numberFormat token 2 '.' ','}}

numberFormatPeriod.png

Format a numerical token value with a comma as the decimal separator

numberFormat

{{numberFormat token 2 ',' '.'}}

numberFormatComma.png

Show verbiage if a token’s numerical value is greater than 1

if, greater

{{#if (greater token 1)}}This verbiage shows if token’s value is greater than 1.{{/if}}

9.jpeg

Show verbiage if a token’s numerical value is less than 1

if, lesser

{{#if (lesser token 1)}}This verbiage shows if token’s value is less than 1.{{/if}}

10.jpeg

Add two tokens’ values to show a result with zero decimal places

add, toNumber

{{add (toNumber token1) (toNumber token2)}}

11.jpeg

Nest Conditional Logic Statements for “And” and “Or” Scenarios

The editor supports nesting multiple conditional logic statements to show verbiage with more than one trigger. In some scenarios, the triggers must both be true to show the associated verbiage (”and” scenarios). In other scenarios, the triggers can both be true, but one can be true while the other is false (and vice versa) to show the associated verbiage (”or” scenarios).

“And” Scenarios

If you reference more than one token for your “and” scenario, use the following example as a reference:

Scenario

Helper(s)

Logic Statement

Real Example

Show verbiage if both token1 and token2 have a value.

if

{{#if token1}}{{#if token2}}This verbiage shows if token1 has a value and token2 has a value.{{/if}}{{/if}}

13.jpeg

“Or” Scenarios

If you reference the same token for your “or” scenario, use a matchesValues statement, shown in Create Dynamic Templates.
If you reference more than one token for your “or” scenario, use the following example as a reference:

Scenario

Helper(s)

Logic Statement

Real Example

Show verbiage if token1 has a value or token2 has a value.

if, unless

{{#if token1}}{{#unless token2}}This clause will show if token1 has a value but token2 does not.{{/unless}}{{/if}}{{#if token2}}{{#unless token1}}This clause will show if token2 has a value but token1 does not.{{/unless}}{{/if}}{{#if token1}}{{#if token2}}This clause will show if token1 has a value and token2 has a value.{{/if}}{{/if}}

14.jpeg


The logic statement format above accounts for all of the potential scenarios encompassed by an “or” (e.g. one, the other, or both). In these scenarios, the first clause shows if token1 has a value, but token2 does not. The second clause shows if token2 has a value, but token1 does not. The third clause shows if both token1 and token2 have values.


Did this answer your question?