Issue in Data Table

Hello Team,
Hope you are doing good. I am processing a workflow for salesOrder edit.
Here i am taking the value of SalesOrder from Queue and Date from config file and the processing further steps.
At the end i want to put both values to DataTable.
But i am getting error in Add Data row.
Please find the attached screenshot. Please let me know for any more information required.
Build Data Table:


Below is the screenshot for Add Data row for which i am getting an error.

The intention is to put the entry in data table after every successfull iteration

Thanks & regards,
Amit Kulkarni

I had some quries,

Why u are looping through an empty datatable out_DT_Data since it is empty, it will throw error.

is this workflow is whole under loop?

can u explain please

It is not possible to loop through a table and at the same time add a new row

Simply use add data row, without looping :slight_smile:

Oh I thought is to first build and then add.
Its not under a loop.It will take entries from the queue

Ok Thanks will try it but in add data row i am not able to add arguements as show in the pic.

Hi @amitkk_84 there is ‘.’ at the beginning of each variables in the add datarow, remove that and validation error will be gone.
image

Regards

Nived N

Happy Automation

I did that but i am getting error as
Add Data Row: Object reference not set to an instance of an object.

Also if the first iteration is over and if there are any items in queue it will agaun process the same workflow and in ideally it should create a new entry in add data row.

Can u please help

Hi you are getting this error because you have not initialized the datatable.
You need to put back build datatable activity.

I put the build data table back and declare local variable and it is working fine but my concern is
for first time it will load the entry but for the second iteration will it overwrite or automatically write it below the first value.
Or do i need to add for loop.Currently my workflow is shown below.

In this case the problem is not the add row activity but the build datatable activity. It will try to re-initialize an existing datatable.

You have two options:

  1. move the activity build datatable in a part of a process that runs only once (eg when reading the config file)
  2. Keep build datatable activity there but use an if statement to check if datatable is nothing .
1 Like

Hello Dimibot,
So what should be done in this case?

I don’t know all the requirements of your process and where exactly you need to use this datatable so i can not give you an answer to your question on which option to choose :frowning:

@amitkk_84

Hi,

Take a variable, Variable type DataRow and assign the value Datatable.NewRow.
For example there is a Add DataRow which has testDataTable.
Then suppose you want to add first data item in a datatable.

Firstname = row(0).ToString
FirstRowData = Datatable.NewRow
FirstRowData(“FirstName”) =Firstname
(AddDataRow)

Please feel free if any doubt.

Regards
Anand

hi @amitkk_84 ,

In add data row activity, in arrayrow property add expression as
{var1,var2}

When you do that, you can see some “.” operator, remove that. And check whether this workflow is running or not.

don’t use any for each row activity.

Thanks a lot it worked.

Will check that out and let you know

Thanks a lot.Will check

Hello Dimibot,
As per your suggestion, i have done blow things.
Declared the build datatable in config which is shown below.

Now in the Process, i am using add data row as shown below.

Now i have a query here as since i have created an arguement and add as B_DT , now how can i use the value in the add datarow where i need to mention the Datatable.

Hi @amitkk_84 ,

Mention over here →
image

Yes but that value is not getting displayed if i search for it.
Am i doing something wrong.