Field Formula String Contains
Trying to evaluate a field (which should be a string of text) to see if it contains certain text.
Javascript methods should work as str.contains(searchtext). Can I use that method in field formulas?
I'm using this but it seems to not be working:
fields['haystack'].contains('needle')
Thanks in advance!
Best Answer
-
Hi @Adam_636382 I think you're looking for the String.includes() method.
I hope that helps.
5
Answers
-
--thanks!
2 -
@Adam_636382 , nice to see you here in Community!
Our help site's action list has many Text actions. These may help as well and these Text actions are easier to use than Field: Field Formulas.
https://help.catalytic.com/topics/actions/
In a recent question (linked below), I shared an example of how I setup Text: Find text next to other text.
Which text action should I use?
https://community.pushbot.com/discussion/10681 -
@Tom_121527 would the correct syntax in a Field Formulas be:
if (fields["haystack"].includes("needle")) { result = WHATEVER YOU WANT HERE; } else { result = OPPOSITE RESULT YOU WANT; }
it's all about the quotes, singles quotes, parenthesis, etc. LOL
thank you,
Kevin0