+ Start a Discussion

Using EQUALS instead of CONTAINS

Hi Hi,

If I use CONTAINS, then the letters kent are mixed up with the United Kingdom's Kent state/province.

How to use equals Kentucky instead of contains?

IF(CONTAINS("Kentucky", State )

I assume that "State" in your IF condition is comma separated string, since if it is set of strings then there is no issue it will automatically check the full word. But it might be comma separated string.

Two option is there

(1) You can convert your comma separated string to set of string like below
Set<String> setStates = new Set<String>();
String[] arrStates = State.Split(',');
for (String strState:arrStates) {

IF(CONTAINS("Kentucky", setStates)

(2) You can check comma with state name in IF condition

But before that you need to append comma in very first and last character like
State = ',' + State + ',';
IF(CONTAINS(',' + "Kentucky" + ',', State )

Thanks & Cheers,

Here is my formula, so where do I insert your solution?

IF(CONTAINS("Kentucky:West Virginia:Pennsylvania:Virginia:", State ),