Check if some value of a transactiondatarow is empty

Hello all,

I am using the reframework, and at time to proceed for each transaction as datarow variable, I would like to know how can I check if some value of the datarow transaction to proceed is empty.

Can you help me with this issue?

Thanks!

1 Like

Hi @Angel_Llull,

I usually do this check:

row("ColumnName") IsNot Nothing AndAlso Not String.IsNullOrEmpty(row("ColumnName").ToString)

1 Like

Thanks for the answer!

But the issue is that I dont know which row of which column can be empty. One day is column A, and another day is Column D…

1 Like

Do you want to know what columns have empty values?

Also, it need to be dynamic because you are not sure what are the column names. I mean, they can vary. Am I right?

Yes, I want it dynamic. I want that robot checks if any column from the row is empty. So this transactions pass to business exception

1 Like

Hey @Angel_Llull ! Convert DataRow to array with

Datarow.ItemArray

Then check if the array contains null value! With this:

arr_vals.Where(Function(x) String.IsNullOrWhiteSpace(x.ToString)).ToArray.Length > 0

Hope it helps!

1 Like

Thanks! I will try it :slight_smile:

1 Like

Awesome solution @gabrielribas4 :clap::clap::clap:

1 Like

Thanks bro @gustavo.cervelin!! :mechanical_arm: :mechanical_arm:

1 Like

Hello @gabrielribas4,

I have a question about the solution, as I am getting an error because there are rows with empty columns that the error is not throwing. I mean, these rows with empty values should not continue the process, and with the function above it is like it is not finding that theses values are empty…

Is that function checkin if all array is empty?

Thanks :slight_smile:

Hey @Angel_Llull !! Lets try another approach:

arr_vals Is Nothing OrElse arr_vals.Length = 0 OrElse arr_vals.Where(Function(x) String.IsNullOrEmpty(x.ToString)).ToArray.Length > 0

Let me know if it works!!

1 Like

checking datarow level
for any column value is null/Empty (assumption: simple datatypes for the columns)

isBlank = row.ItemArray.Any(Function (x) isNothing(x) OrElse String.IsNullOrEmpty(x.toString.Trim))

Checking entire Datatable Level (all rows, all columns)

hasBlanks =

(From d in dtDataVar.AsEnumerable
Let chk = d.ItemArray.Any(Function (x) isNothing(x) OrElse String.IsNullOrEmpty(x.toString.Trim))
Select x=chk).Any(Function (x) x)
1 Like