For Each Row Datatable Object Reference Not Set

Hi! I am planning to loop through each row of a data table, and input the 4th column into a web textbox.
However, I encountered this error:

For Each Row in Data Table: Object reference not set to an instance of an object.

How do I solve this? I also want to view my data table, just to understand if I have imported it correctly. Thank you!!

Edit:
Thanks everyone for how to check if CleanedData contains value! I have checked it and it indeed has not been written.


How do I store the data table and use it for the browser? Does it has something to do with scope? Thanks!

Have you put the type into activity in use browser / application scope?

Also check the datatype of PN

Other way is to check content of each variable here using breakpoints and debug check if it has all the needed contents

@Hou_Paang_Soul

Pass the data table variable into an output data table activity and pass the output of the output data table activity into message box so that it helps to print the data table in message box.

Or else

Use the message box and write the syntax in that

datatablevariable.Rows.Count

Regards

1 Like

Hi @Hou_Paang_Soul

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

@Hou_Paang_Soul

Looks like the datatable is empty or null…

please check …you can open locals panel and see if there is data

cheers

Hi,

I guess CleanedData is null. Can you try to check content of CleanedData at Locals panel when error occurs or break point?

Regards,

Hi!

To verify that you are retrieving the data table correctly, set a breakpoint and check the contents of the data table variable with a watch


1 Like

@kimjinseong

Change the Scope of that variable to the outermost scope, and make sure you don’t have two variables of same name.

The list of items value may be null for for each activity to provide object reference is null

@Hou_Paang_Soul

If you find the solution for your query please mark as solution to close the loop

Regards

Hi! I have checked that the CleanedData was indeed empty. I have put the scope to be for the whole flowchart, it is still empty.

Hi! I have checked that the CleanedData was indeed empty. I have put the scope to be for the whole flowchart, it is still empty. Thanks for pointing out the debugging process!

1 Like

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