Add Data Row Investor Name: Object reference not set to an instance of an object

Can Someone help out?

Hi @rodrigo.simao

Object reference not set to an instance of an object will come when the variable or argument is empty.

So, what is being stored in dt.

Regards

Go to where you have the datatable variable defined, expand the Variables pane at the bottom, and type New System.Data.DataTable into its default. This initializes it as an empty datatable. You’re getting the error because it’s not even an empty datatable, it’s a null variable.

Thank you very much @postwick, I resolved an issue but I just got another that consists of my array being with 32 null values and my variables that populate the array have values as you can see in the print.

Hope you can help like you always do :slight_smile:

That error actually isn’t because of the nulls. That error is because you have more elements in your array than there are columns in the datatable.

As for the nulls, you’ll have to go back to where you populate the array and figure out why it isn’t populating.

Let’s back up a little bit. Where is the data coming from? Where are you getting the values that you’re trying to add to the datatable?

So I’m getting them from a PDF using the “Get Text” activity and then once the variables have a value I just did this:

{InvestorName,InvestorNumber,FundName,ShareClass,MonthBeginningEquity,YearBeginningEquity,MonthContributions,YearContributions,MonthWithdrawals,YearWithdrawals,MonthNetProfitLoss,YearNetProfitLoss,MonthEndingEquityUSD,YearEndingEquityUSD,MonthOpeningUnits,YearOpeningUnits,MonthUnitsIssued,YearUnitsIssued,MonthUnitsRedeemed,YearUnitsRedeemed,MonthEndingUnits,YearEndingUnits,MonthNAVperShareBeginningOfPeriod,YearNAVperShareBeginningOfPeriod,MonthNAVperSharePreDistribution,YearNAVperSharePreDistribution,MonthDistributionPerShare,YearDistributionPerShare,MonthNAVperShareEndOfPeriod,YearNAVperShareEndOfPeriod,MonthRateOfReturn,YearRateOfReturn}

On the default value of the array variable.

As for the columns I already checked and I have the exact number of columns as I have of Items present in the array (32).

You can’t do that in the Default, because the Default is processed when the job (or scope the variable is in) starts, and those variables don’t yet have values. Just put that whole thing into the Add Data Row activity.

By the way, collecting that many individual data points with Get Text is very tedious. If Get Text works, then that means there are selectors and there must be a better way. Have you tried Table Extraction? Even a For Each UI Element could be used and as it loops you put the label and value into a dictionary as a key/value pair. Then in the Add Data Row you use yourDictionaryVar.Values to get an array of the values. You could even use yourDictionaryVar.Keys (array of the labels) to create the necessary columns in the datatable (if they don’t already exist)

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