For Each Row: Object reference not set to an instance of an object UiPath

Dear All,

When i try to import data table by using For each row, an error message is displaying as For Each Row: Object reference not set to an instance of an object.

The scenario is to add the data table as quueue item.
Also Item Information is added as the same path in config.
Let me know if there any arguments or variables that i need to check.

1 Like

Usually I encounter this if the datatable is null. Try to initialize your datatable variable to “New Datatable” and make sure that your dt has content.

4 Likes

HI @Htwe_Ko_Ko_Wynn

Welcome to UiPath Community!

Can you verify if the dt_workitems has some rows?

Thanks,
Prankur

2 Likes

@Htwe_Ko_Ko_Wynn use below in condition
row(“Type”).Equals(“WI4”) and row(“Status”).Equals(“Open”)
image

2 Likes

Hi
Welcome to uipath community
Before this for each row loop use a writeline activity and mention the input string like this
datatable.Rows.Count.ToString

This will display and helps us in validating whether the datatable has any records in it or not

If it’s there then we won’t face this issue
Or
If it has no records then we need to check whether the variable passed as input if is obtained from a argument, it should be set with proper direction like IN or OUT
Or
If it’s obtained inside a excel application scope and and a read range within it then make sure that the variable is set with global scope of sequence in variable panel

Cheers @Htwe_Ko_Ko_Wynn

2 Likes

Hi Marci,

May i know step by step process to perform your suggestion?

In the variable panel
For the datatable variable assign a default value as
New System.Data.Datatable

Or if it’s a argument
Before to this for each row loop use a assign activity like this
datatable_variable = New System.Data.Datatable

But we need to clarify this like whether it has any value or not
Cheers @Htwe_Ko_Ko_Wynn

3 Likes

Just what Mr.@Palaniyappan said for the initialization (default value). When the DT is initialized, this error will not appear and you can see clearly whether it entered your for-each row or not (= your dt is empty or not).

Then, recheck the place/activity where you are assigning the value for the DT - whether it indeed successfully assigned the data to it.

4 Likes

Can anyone solve this?
04/18/2023 21:01:41 Get Row Item: Object reference not set to an instance of an object.

. Thanks in Advance.