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

I have searched for every answer on this forum related to this topic.
But none of those solutions worked for me.

My requirement : I am trying to copy individual transactions(Which are data rows) to an excel sheet.
The logic is that i am testing a condition on individual transaction.Only if the transaction fulfills that condition should i copy the data to excel.

I tried the below code:

The error i received is : Add Data Row: Object reference not set to an instance of an object.
i figured out that in_TransactionItem.ItemArray is probably empty despite in_TransactionItem having data.However in_TransactionItem.ItemArray doesnt have data being passed.

I even tried to print the value of in_TransactionItem.ItemArray.But its printing some system.row kinda thing.(Not the value)

Am i missing out on some information ? Any initialization or something to ensure data is passed from in_TransactionItem to in_TransactionItem.ItemArray.

Suggestions are welcome.Thank u.

If your data table have only one row, then you can pass the transactionitem as
{ transactionitemvariable }

If it has three rows and the column you want to add value is the second one, then pass it as

{0 or null, transactionitem , 0 or null}

here 0 if the column is of type integer and null or string.empty if the column is of type string @Vidya_Srinivasan

My data table is consisting of all transaction items put together(Transaction Data).
but i want to fetch individual transactions(Data row),apply filter and on passing criteria paste to excel.

Can u share any screenshot of the code u r suggesting?
I didnt understand where i need to implement it.

Sorry for the confusion, I mean the data table has only one column, then pass it as above mentioned @Vidya_Srinivasan :slight_smile:

Here is the screenshot

  1. If you have only one column

  2. If you have more columns,

I updated it to what was suggested.

However my error remains the same.


That is based on the number of columns in your data table @Vidya_Srinivasan… Check the value in the variable is not null first and then pass the parameters based on the number of columns

@Vidya_Srinivasan did you ever get this to work? I am trying to do the same thing and it’s driving me crazy trying to get this correct! Thank you

Hi Chris,

I used a different logic to filter my datatable.
I used select command on my data table and held it in a variable which was of type (Array of datarows).

And then used index concept to hold a single row in that array into a variable of type datarow.

After that filter out each datarow using if loop on that data row.
Use append range to add items to the sheet.

Let me know if it helps.

I am just needing to process a row of data in REFramework and after deciding on the action for that row, at that row of data to a datatable. Seems it would be simple but doesn’t seem to be.