This article explains what the Contains() operator is and provide examples of how it can be used with the binding syntax in smart templates.
Prerequisites
- Library and at least one Dynamics module enabled.
- Templafy Desktop and Office VSTO add-in installed.
-
Space owner access to the Templafy tenant.
|
What is the Contains() operator?
Contains() is an operator that returns True/False depending on a Source value containing a Search value. Contains() is case sensitive, comparisons between two values that might be using different casings can be achieved by using a Lower() or Upper() function together with Equals().
Contains() logic
Contains() operator examples
Example 1
Using the Contains() operator to check if a sentence contains the word "random" (case-sensitive).
Example 2
Using the Contains() operator together with Lower() to match the casing used and make a comparison.
Example 3
Using the Contains() operator together with Not() and Lower() to match the casing used and make a comparison.
Example 4
Using the Contains() operator together with IfElse() and Lower() to verify if the input entered in the "Body" question originating from the response form contains the word "legal" (not case-sensitive as the Lower() function is used). If the "Body" contains "legal" the output should be "There is legal text in the above document. Ensure it's legally compliant.", otherwise insert an empty input.
Example 5
Using the Contains() operator together with IfElse() to display or hide some text based on the value of the "Office.Name" originating from the User Profile.
- If the "Office.Name" is "Copenhagen" or "Berlin", the text should be hidden.
- If the "Office.Name" is anything else, the text should be shown.
Example 6
Using the Contains() operator together with IfElse() to see if the "Subject" question originating from the response form matches any of the comparison values (large, cat, small, dog). If the values are "large", "small", "cat", or "dog", the output should be "Match", otherwise "No match" should be shown.
Based on the example above, you can also add the Concat() function to see if the "Subject" question originating from the response form matches exactly any of the comparison values (large cat, small cat, dog). If the values are "large cat", "small cat", or "dog", the output is "Match", otherwise "No match" is shown.
Note
- In this example, the output for "cat" is "No match", because "cat" is neither equal to 'large cat' or 'small cat'. It is not an exact match.
- Instead of '##' any other characters can be used, e.g. '@' or '+++'.
|
Example 7
Using the Contains() operator together with IfElse() to see if the "Subject" question originating from the response form matches any of the comparison values (large, cat, small, dog) and adjust the text visibility. If the values are "large", "small", "cat", or "dog", the output should be shown, otherwise, it should be hidden.
Based on the example above, one can also add the Concat() function to see if the "Subject" question originating from the response form matches exactly any of the comparison values (large cat, small cat, dog) and adjust the text visibility. If the values are "large cat", "small cat", or "dog", the output should be shown, otherwise, it should be hidden.
Note
- In this example the output for 'cat' is Hidden text, because 'cat' is neither equal to 'large cat' or 'small cat'. It is not an exact match.
- Instead of '##' any other characters can be used, e.g. '@' or '+++'.
|
Comments
Article is closed for comments.