I'm looking to screen 300 keywords against the body of an email (Email.Message.Body) in Architect.
I've tried to do a case-insensitive string collection (e.g. FindFirst(CollectionName,ValueToFind)), but this doesn't seem to match in the email body.
Is there a better way to screen a large amount of keywords other than doing 300 contains checks, knowing that we're limited at 60 deep, so I'd have to do several blocks?
What are you using for CollectionName and ValueToFind? If you're using the list of keywords as CollectionName and the email body as ValueToFind, that means you are trying to find the entire email body as one of the keywords.
You an use a loop to go through the keywords and see if each one is in the mail. If you find a match, you can exit the loop instead of going through the rest of the keywords. You will go through the loop at least once and up to 300 times, depending on whether a match is found or not. FWIW, I'd order by keywords by highest to lowest frequency to match so the loop loops the fewest times as possible on average.
Contains doesn't do regex, so there's a couple possibilities.
Example 1: to get high followed by a space, comma, or period:
Contains(Email.Message.body, "high ", true) or Contains(Email.Message.body, "high,", true) or Contains(Email.Message.body, "high.", true)
This solution can work easily for any word. The drawback is you have to add all cases you can think of. If the email ends with exactly high, this would fail. There could also be new line characters, emojis, etc.
Example 2: check to see if it contains high but not higher:
Contains(Email.Message.body, "high", true) and !Contains(Email.Message.body, "higher", true)
Here you have to know specifically what you don't want.
Example 3: split the body into a string collection then look for your word. You would also need to loop through the array, examine each value to get rid of periods & commas and use Lower to downcase it before using the FindFirst function to look for "high". This should work for any word, it's just the most amount of work.
Thank you for the ideas! I was testing on my own, and am I missing a limitation, or would FindString also work in this case?
For example, FindString(Email.Message.body, Flow.Keywords[State.indexPosition], true) > 0