Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Need help using the "contains" function

Avatar

Level 5

The documentation for "contains" isn't too helpful ... the (Hello World,Hello) example doesn't show how to check a field.

I'm trying to see if a field contains the word Anniversary. If true, I'll set a project ID. If not, nada. Right now, I'm just testing and I'm getting nowhere.

0694X00000Asaz1QAB.pngI know the field contains Anniversary, but I keep getting a false. Anyone out there know how to do this?

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi Howard,

Your variable value is so close! But missing a semicolon.

right now your function is something like:

{{if(contains(1.`Some Text Value`; "Anniv") + "Anniv Found"; "Anniv Not Found")}}

but it should be:

{{if(contains(1.`Some Text Value`; "Anniv"); "Anniv Found"; "Anniv Not Found")}}

(you can copy and paste this text and then you can swap out the variable values.

contains works as you would expect, returning a true or false if the value is found in that text. In this situation, the contains was not actually the problem. Instead, your if statement was missing the semicolon after the first expression. As a useful tip in the future, you can strip out the if and test the contains by itself to get more insight.

I should also note that "contains" may work differently if you are dealing with an array. I've attached a simple blueprint you can import anywhere to confirm how it works with both a text and an array. I hope this helps.

0694X00000AscQSQAZ.png

View solution in original post

2 Replies

Avatar

Correct answer by
Level 4

Hi Howard,

Your variable value is so close! But missing a semicolon.

right now your function is something like:

{{if(contains(1.`Some Text Value`; "Anniv") + "Anniv Found"; "Anniv Not Found")}}

but it should be:

{{if(contains(1.`Some Text Value`; "Anniv"); "Anniv Found"; "Anniv Not Found")}}

(you can copy and paste this text and then you can swap out the variable values.

contains works as you would expect, returning a true or false if the value is found in that text. In this situation, the contains was not actually the problem. Instead, your if statement was missing the semicolon after the first expression. As a useful tip in the future, you can strip out the if and test the contains by itself to get more insight.

I should also note that "contains" may work differently if you are dealing with an array. I've attached a simple blueprint you can import anywhere to confirm how it works with both a text and an array. I hope this helps.

0694X00000AscQSQAZ.png