Null value in datatable causing error using If activity

I am using the if statement embedded in a For Each Row loop to apply different values to another variable depending upon the value of one of the columns in the datatable. The last row in the datatable does not contain anything and is throwing the error, “Object reference not set to an instance of an object. Exception type: System.NullReferenceException” I have tried setting the variable to default to “” but that did not help. Can anyone assist with this?

Perhaps clean the datatable before entering the for each and remove the last row? Otherwise, add another If activity to check if it’s the last row and only continue if it’s not.

Hi @lhendrix,

After for each use an if condition to check whether the row is Null or empty.


If the above expression is true then only you perform the operation

Thanks for your help, all. I have included a screenshot of what I did in case it helps others. image

Hi @lhendrix

Use the condition in If


So the above expression checks both conditions whether string is Null or empty