String.Contains in FlowDecision

Hello everyone

I have a problem with my second Flow Decision.
image

I have tried two conditions. First, I tried the following condition.

list_name.Any(Function(x)string_name.Contains(x))
The problem is that the second condition was always true.

I also tried the condition:

list_name.Contains(string_name)
The problem here was that the strings from the list were not recognized. It’s only recognized if the strings are exactly the same. It’s not recognized if the string from the list is called “equipment” and the string_name is “equipment test”.

I get my string from Excel.
It has the format:

equipment 1;equipment 2;equipment 3;…

Then I assign the strings into a list with.

str_name.Split("; "c).ToList

Thanks for your help :slight_smile:

Why would it? “equipment” doesn’t contain “equipment test”

“equipment test” does contain “equipment”

I think your logic is backwards.

You have a space there after the ; but there is no space in your data. Also, if all you’re doing is a contains, there’s no reason to split it. And Split gives an array, so why are you doing .ToList? It’s redundant.

What is your logic supposed to be? Explain your goal.

Hello @Jananthan, Welcome to the UiPath community.
From my understanding, you have to set the conditions as a string_name.Contains(list_name)

Because , we have to check the word equipment available in equipment_test.
Don’t look the equipment_test in equipment → it returns false.

Hi @postwick

Thanks for pointing this out. I have now changed the Condition to string_name.Contains(list_name).

The space after the ; is a mistake, it should be str_name.Split(";"c).ToList.
I created the list to be able to compare each word in the list with the variable “string_name”.
My goal is to compare predefined words with a variable.

Hi @Gokul_Jayakumar

Thanks for the answer.
I tried this, but I get an error. I can’t convert a list(of string) in string.
When I write String_name.Contains(list_name.toString) then the condition shows false when it should be true.

Terry like this @Jananthan

String_name.Contains(String.join(“,”, list_name))

That’s not going to work. One value will never contain all the values put together with a join.

Hi @Sudharsan_Ka
I tried that too, but that doesn’t work either. The condition shows false when it should be true.