Search value in Datatable in IF activity

Hey guys, this one is bugging me.

I’ve got a datatable with hundreds of ID numbers(42343248,823434 etc) in a for each row loop.
Each row is assigned a ID variable(Pref1) Then I’ve got a datatable DT1 which has 16 rows of ID numbers. I want the IF activity to check the current Pref1 variable against the 16 in DT1, and there is matches go the ELSE path.

Right now i’ve solved it by simply putting all the individual IDs in the IF(IF pref1=“43434” or if pref1 =“534” etc etc. But its so messy.See attached image.

Is there a way write the IF different so that it checks each row in DT1 at once, without having to specify each ID like im doing now?

let me know if i need to explain further.


there are many ways to solve it, one could be following:

transform dt1 with the 16 values to a list:
dt1.AsEnumerable.Select(Function (row) row(0).toString.trim).toList - (myIDList)

Now you can check if the current row/column value is contained in the 16 Values list with
myIDList.Any(Function (x) x.equals(myRowColValue))

Hi @thomasb82

Create a variable of array of String, set it default value to {“42343248”, “823434”, etc}
Then you can write the IF source as SQLPNR = “” OrElse array.contains(pref1)

hey, thanks for the help, it worked great!

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