VisualBasicValue<Boolean>: Object reference not set to an instance of an object

Hello,

TLDR: When I use Lookup Range activity and it fails, then the succeeding Flow Decision activity returns Object reference error even when I have initialized the variable that I’m using in the expression of Flow Decision activity.

I want to automate a process where the robot searches for an EmployeeName in an Excel sheet, returns its cell ID and store its next cell value in a List. For e.g. Robot will search for “John” in the excel sheet which returns CellID = B21, so the value of C31 will be stored in an EmployeeTimeList (List).

I have a pre-defined List containing all Employee Names and the robot should search for all the items in the List one by one. I’ve used Lookup Range activity and initialized the CellID = “”, if the name is found using Lookup Range then the returning value will be re-assigned to CellID, in other case where the name is not found, then the value will be CellID="". I’m then using Flow Decision to check if the CellID.Equals("").

The error occurs in Flow Decision activity, when it matches the expression i.e. CellID.Equals(""), at this stage I get an Object Reference Error, but I’ve already initialized the CellID = “”.

I’ve attached workflow for troubleshooting purposes. Please let me know if you’ve any trouble understanding the process.
Main.xaml (31.1 KB)

Regards,
Deepak N.

1 Like

Hi @deepak.naidu

It would indeed seem like the Lookup Range activity reinitializes the output variable with a null value if nothing was found.

I think the quickest you can get it working is by checking for a null value instead of an empty string, like so:

IsNothing(CellID)

This will return true if the value is null, effectively fixing your exception.