If activity with OR expression

Need help with If activity with OR expression.I have Array of Strings eg:
myarray = {“Apple”, “Orange”, “Kiwi”, “Banana”, “Peaches”, “Plum”}
I need check if its “Kiwi” or “Plum” then exclude it.
I have wrote condition couple of ways but it’s not working
Using for loop:
for fruit in myarray
Condition: Not fruit.ToString.Equals(“Kiwi”) OR Not fruit.ToString.Equals(“Plum”)
And also tried this
Condition: Not fruit.ToString.Equals(“Kiwi”) OrEsle Not fruit.ToString.Equals(“Plum”)

Hi @rathi.sham

Give a try with the following

Not (fruit.ToString().Trim().ToUpper().Equals("KIWI") Or fruit.ToString().Trim().ToUpper().Equals("PLUM"))



Can you try AndAlso instead of OrElse (Or) because Not A or Not B always returns true if A and B are independent.


1 Like


You can directly remove them from array as well

NewArray = Myarray.Except({"Kiwi,"Plum"}).ToArray



Thank you All, those were all good solutions.
Much appreciated!

1 Like

If NOT ({“Apple”,“Orange”,“Kiwi”,“Banana”,“Peaches”,“Plum”}.Contains(“Kiwi”) or {“Apple”,“Orange”,“Kiwi”,“Banana”,“Peaches”,“Plum”}.Contains(“Plum”))

1 Like

Hi @rathi.sham

Try this LINQ function to filter the array and return only the items that do not match those two values.

  1. Use an Assign activity to create a new filtered array:-
    filteredArray = myarray.Where(Function(fruit) Not fruit.Equals(“Kiwi”) AndAlso Not fruit.Equals(“Plum”)).ToArray()

  2. Use an If activity to check if the original array contains “Kiwi” or “Plum”:
    myarray.Intersect({“Kiwi”, “Plum”}).Any()

This expression returns True if the original array contains any of the values in the set {“Kiwi”, “Plum”}.



This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.