This topic will walk you through how to create advanced conditional logic for Ironclad Clickwrap. This topic is specific to the Classic Clickwrap Experience.
This topic is specific to the Classic Clickwrap Experience. If you are using the Classic Clickwrap Experience, refer to the New Experience Clickwrap documentation.
On occasion, you may need to employ more advanced conditional logic to dynamic contracts in order to render the appropriate verbiage under different circumstances.
Use Advanced Conditional Logic
Below are some examples of advanced conditional logic that can be applied to your dynamic contracts.
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 | {{#if token}}This verbiage shows if token is true or not null.{{else}}This verbiage shows if token is false or null.{{/if}} | |
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}} | |
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}} | |
Format a token’s value to be uppercase | uppercase | {{uppercase token}} | |
Format a token’s value to be lowercase | lowercase | {{lowercase token}} | |
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}} | |
Show the current date | formatDate | {{formatDate now “MM/DD/YY”}} | |
Format a numerical token value to have two decimal places | numberFormat | {{numberFormat token 2}} | |
Format a numerical token value with a period as the decimal separator (default) | numberFormat | {{numberFormat token 2 '.' ','}} | |
Format a numerical token value with a comma as the decimal separator | numberFormat | {{numberFormat token 2 ',' '.'}} | |
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}} | |
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}} | |
Add two tokens’ values to show a result with zero decimal places | add, toNumber | {{add (toNumber token1) (toNumber token2)}} | |
Add two tokens’ values to show a result with two decimal places | add, toNumber | {{add (toNumber token1) (toNumber token2) 2}} |
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}} |
“Or” Scenarios
If you reference the same token for your “or” scenario, use a matchesValues statement, shown in Create Dynamic Contracts.
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}} |
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.