For Each Row : Message : Object Reference not set to an instance of an object."

I am trying to extract content from a excel and update that in google form.
However, I am stuck with below error and not able to move forward, pls help.

1 Like

Hi
Welcome to uipath community
Make sure that the datatble variable from READ RANGE is set to global scope ie to whole sequnce in the variable panel
We can set that in the scope field of variable panel
Once after changing that m, we won’t face this issue

Cheers @pravinnm

Do you have any records in you “readdata” data table?
You cold easily find it using debug.

Cheers

@pravinnm

Hello and welcome to the Community.
The exception type refers to a NullReferenceException, so looks like you are trying to use some variable which is referencing to Null.

Please us the debug mode to check the same.

Yes it is already set to entire flowchart, not just to specific activity.

1 Like

Awesome
Can I have a screenshot of READ RANGe Activity property panel if possible
Pls ensure that same output variable name from read range is mentioned as input to this for each row loop and also that read range activity is set with right excel sheet which has some data in it

Cheers @pravinnm

I myself believe it is not connected correctly, but not able to identify. I ran it in debug mode as well, you can see below errors.

Hello, I have ran it in debug mode as well, but couldn’t identify where’s the prob. I have shared the screenshot above.

This is the property panel of excel application scope buddy
Would like to see for read range activity
Cheers @pravinnm

I am new to this, so please bear my ignorance. Does the readrange activity, have to be used outside of this entire activity. I had followed exactly the same as shown in one of the Youtube videos. Please suggest if i should add a readrange actiivty, outside of the excel scope.

1 Like

No buddy
It has to be used within excel application scope
Unless it is from workbook activities we won’t be able to use them outside a excel application scope
I would like to suggest you with some courses from our UiPath academy https://academy.uipath.com
Where we have got level 1 training for foundation course
That would give you more idea about the basics and many other kind of activity like this

Cheers @pravinnm

Sure, Is this the level 1 course - UiPath StudioX Training
Also I have used readrange within the excel scope, were you expecting further drill down in the readrange box.

1 Like

That’s level-1 foundation training course

Yah we need to ensure that the datatable variable that we have obtained as output from read range activity should be mentioned in for each row activity
And also ensure that we have got some data in it

For that validation use a write line activity like this. Who’re the for each row activity
Yourdatatable.Rows.Count.Tostring
Where this will show us with some count in the output panel if there is any record in the variable

Cheers @pravinnm

1 Like

Hi,

This might happen when you trying to manipulate the null value.

For Ex.

In for each row im trying to do some split operation like row(0).tostring.split(“.”.ToCharArray)(0) , If the row value is null then you will get this error. To avoid this error, you can use below code.

If(row(0).tostring <> “”,row(0).tostring.split(“.”.ToCharArray)(0), row(0).tostring)

Try it and let me know if it works….!

Thanks,

David.

@pravinnm Can you please share Screenshot of Read range activity property panel .
Make sure the Datatable you are using for For Each Row is same and not null . You can use the row count to ensure the same . These error occurs when your variable is pointing to null value so be sure the DataTable has the required fields .

@pravinnm Also Be sure the Scope of the variable of Datatable to be for the Whole Sequence /Flowchart . The reason behind that is you are using the FOR EACH ROW outside the Excel Application Scope So you need to extend the scope of DT also .

Most likely the problem is in Read Range activity. So place a breakpoint there and after execution of this activity verify that “readdata” data table contains any data.

Cheers

Is that what you were looking for?

1 Like

Is that what you were asking for?

David, this did not work…same error