This article explains what functions, conditions and operators are in Templafy, where they can be used in smart templates and which can be used with the binding syntax.
Prerequisites
|
Functions, conditions and operators can be used together with the binding syntax to achieve more complex use cases than the default behavior provided by the smart fields. When inserting a smart field it might be necessary to adjust the default binding to achieve the intended result.
Function example
In the smart document, the user should pick a date in the response form. Based on the date input from the response form, the date in the document must be 30 days after the date chosen by the user. This can be achieved by using the DateAdd() function together with the binding syntax of the date: {{DateAdd(Form.Date, 30, "d")}}
Condition and operator example
In the smart document, the user should choose the classification (public, internal, or confidential) in the response form:
- If the chosen classification is confidential or internal, the disclaimer should be visible in the document.
- If the chosen classification is public, the disclaimer should not be visible in the document.
This can be achieved using the IfElse() condition with the Equals() operator in the binding syntax of the classification: {{IfElse(Equals(Form.Classification.Name, "public"), VisibilityType.Hidden, VisibilityType.Visible)}}
Supported functions, conditions and operators
There are different types of functions, conditions and operators that can be used in smart templates. Below is a comprehensive list of the available functions, conditions and operator linked to deep-dive articles.
General functions
Function | Description |
---|---|
DataSources[] | Gets the value from a specific column and row within a data source. |
ExternalDataSources[] | Gets the value from a specific column and row within an external data source. |
Translate() | Translates terms or complete sentences by using values from the Translations data source. |
Text functions
Function | Description |
---|---|
Concat() | Joins two pieces of text together. To join more pieces of text and/or use a separator use the StringJoin() function. |
Lower() | Converts text to lowercase, e.g. 'HELLO WORLD' becomes 'hello world'. |
Proper() | Converts text to proper case which means every word is capitalized, e.g. 'hello world' becomes 'Hello World'. |
SentenceCase() | Converts text to sentence case which means the first word is capitalized, e.g. 'hello world' becomes 'Hello world'. |
StringJoin() | Joins multiple pieces of text together with a separator in between. This function is more advanced then the Concat() function. |
StringSplit() | Separates text with a separator in between into multiple pieces of text. |
Upper() | Converts text to uppercase, e.g. 'hello world' becomes 'HELLO WORLD'. |
Date functions
Function | Description |
---|---|
DateAdd() | Calculates a date based on another date. It adds days, weeks, months, quarters or years to the source date. |
DateSubtract() | Calculates a date based on another date. It subtracts days, weeks, months, quarters or years from the source date. |
DateValue() | Converts plain text dates into a date object that can be used in other date functions like FormatDateTime(). |
FormatDateTime() | Formats date and time, so that the output becomes e.g. 'd-M-yyyy' while the input is 'yyyy/MM/dd'. |
Now() | Shows the current date. |
Numerical functions
Function | Description |
---|---|
Add() | Returns the sum of two numbers, e.g. '11' when the input is '8' and '3'. |
Divide() | Returns the quotient of two numbers, e.g. '8' when the input is '24' and '3'. |
Equals() | Can be used together with the IfElse() function and returns output based on the condition if the number value entered is equal to the number used in the expression |
FormatNumber() | Formats numbers, so that the output becomes e.g. '0025' while the input is '25' or the output becomes '$1,234.00' while the input is '1234'. |
GreaterThan() | Can be used together with the IfElse() function and returns output based on the condition if the number value entered is greater than the number used in the expression. |
LessThan() | Can be used together with the IfElse() function and returns output based on the condition if the number value entered is less than the number used in the expression. |
Multiply() | Returns the product of two numbers, e.g. '24' when the input is '8' and '3'. |
Subtract() | Returns the difference of two numbers, e.g. '5' when the input is '8' and '3'. |
Ticks() | Returns a unique 18 digit number based on the current date and time. |
Conditions and operators
Condition/Operator | Description |
---|---|
And() | Operator that returns true if all values are true and false if at least one value is false. |
Contains() | Operator that returns true or false depending on if a source value contains the search value. |
Equals() | Operator that returns true or false depending on if two values are equal or not. |
IfElse() | Returns output based on if the condition is met. Also see the Switch() function. |
Not() | Operator that reverses a true/false statement, where true becomes false and false becomes true. |
Or() | Operator that returns true if at least one value is true and false if all values are false. |
Switch() | Compares one value to multiple values. If none of the values matches the input then it returns a default value as output. Also see the IfElse() function. When there are many values to compare to it's easier to use Switch() than IfElse(), because that would require a binding with nested fields. |
Use of functions, conditions and operators in smart templates
Functions, conditions and operators are usually used in the Template tab with smart fields or in the Advanced tab with the template settings and properties.
Comments
Article is closed for comments.