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

I am reading a datatable dt_SAPMapping and after that i am using a flow decision condition is dt_SAPMapping.AsEnumerable().Any(Function(row) row.Field(Of String)(“Mapping Ptyp not allowed”).Equals(in_str_ItemCategory)) and it is giving me ablove error and the value of var in_str_ItemCatagory is ZNN…I want to check if ZNN is there in “Mapping Ptyp not allowed” column…Please Help

Hi @Aparna_30

The “Object reference not set to an instance of an Object” error occurs when a variable that is supposed to hold an object is found to be null.

Check the dt_SAPMapping datatable variable which contains data or not and check the in_str_ItemCategory variable. Try to debug the code and check the variable values in the Immediate panel.

Hope it helps!!

Both dt_SAPMapping and the var having the data actually

@Aparna_30,

The error you are encountering, Object reference not set to an instance of an object, suggests that there might be null or empty values in the column “Mapping Ptyp not allowed” which are not being handled properly.

When you try to call .Equals on a null value, it throws this exception.

To resolve this, you should modify your condition to handle null or empty values properly. You can use the String.IsNullOrEmpty method to check for null or empty values before calling .Equals.Here’s how you can adjust your condition in UiPath Studio:

dt_SAPMapping.AsEnumerable().Any(Function(row) Not String.IsNullOrEmpty(row.Field(Of String)("Mapping Ptyp not allowed")) AndAlso row.Field(Of String)("Mapping Ptyp not allowed").Equals(in_str_ItemCategory))

This modification ensures that you only call .Equals on non-null and non-empty strings, thus avoiding the Object reference not set to an instance of an object error.

Thanks,
Ashok :slightly_smiling_face:

2 Likes

Might be there is empty rows in the ‘Mapping Ptyp not allowed’ Column. You can try the LINQ Expression given by @ashokkarale

Hope you understand!! @Aparna_30

1 Like

Resolved…Thank you @ashokkarale AND @mkankatala

2 Likes

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