Assistance with checking information in string

Hey, wonder if someone would be able to point me in the right direction - on one of our apps we are building we are trying to capture some characters which we would use to send that user to a different flow. For example if the user’s policy number contains “ABC” to then show the user different information. I tried using CONTAIN without any success. If someone can help that would be great.


The function CONTAINS searches through Lists, but it sounds like you need to search through a string. For that, I’d use STRING_FIND nested inside an IF function.

For instance, say you have some string, call it sample_string. You want to see if it contains “ABC”, so you run STRING_FIND(sample_string, "ABC"). This will return -1 if “ABC” cannot be found within sample_string. To turn this into a Boolean, perhaps for use within the Condition Action, you can nest it within the IF function like so:

IF(STRING_FIND(sample_string, "ABC") = -1,  FALSE, TRUE)

This will return FALSE if sample_string does not have “ABC” as a substring, and TRUE otherwise.

Does that help?


Hi Chandra,

Thank you for your response, I’ll give it a go.

Am I able to use sessions inside of the sample_string so if the session variable contained “ABC” then it would pick it up.

For example if session.quoteNumber = “ABC” this would return true.


You are able to use variables within Airkit expressions, and global variables (indicated by that session namespace) are available everywhere! So if you have a global variable designated quoteNumber, you should be good to go with something like:

IF(STRING_FIND(session.quoteNumber, "ABC") = -1,  FALSE, TRUE)

(And yes, if session.quoteNumber = “ABC” this would return TRUE.)

The string “ABC” can also be substituted with a variable. Say you had a global variable designated search that was equal to “ABC", then you could get the same results with this:

IF(STRING_FIND(session.quoteNumber, = -1,  FALSE, TRUE)

The devil’s in the details, though, and variables need to be stored locally in order to be accessible. The doc Variable Scopes might if be a good place to start if you’re running into issues regarding what variables you have access to in a particular Airscript expression.

1 Like