Contains Text
Learn how to compare and evaluate text stored within a Keyfax databox.
Last updated
Was this helpful?
Learn how to compare and evaluate text stored within a Keyfax databox.
Last updated
Was this helpful?
To check for the presence of a specific string within a databox the following approaches can be used. Which approach you use may depend upon your specific requirements.
DANGER It's important when using the CHARINDEX function and / or LIKE operator below that you don't allow user supplied input within your SQL databoxes. Only fixed text databoxes or hardcoded values should be allowed within Keyfax SQL databoxes.
In the example below we've created 2 text questions asking the user for text to search and the string to find. This supplied input is captured within two Script databoxes.
The "Text is present" SQL databox below is then used to check if the "Text to search" Script databox value contains the string captured within the "Text to find" Script databox value.
You can see this example below...
The "Text is present" SQL databox above performs the logic to determine if the string was found anywhere within the source string as shown below...
The SQL code for the above SQL databox is enclosed below...
To verify this is working as expected during development the following message coud be displayed if a match is found (i.e. the SQL databox returned 1 or above). 0 will be returned if no match is found.
You can use the "Test" button to test your SQL databox via Keyfax Administrator Tools. Within Keyfax you would then see the test message from above like so to verify the string is being found...
The LIKE operator is used in a WHERE clause to search for a specified pattern in a string.
There are two wildcards often used in conjunction with the LIKE operator:
The percent sign %
represents zero, one, or multiple characters
The underscore sign _
represents one, single character
For example the following SQL databox will return 1 if the databox value contains AST and zero or more characters after...
Should you have any further quesitons please don't hesitate to Contact Us