How to input vars into data table

datatable
activities

#1

Hello,

I am trying to input variables into a data table that is built in the beginning of a sequence.

The sequence goes like this (macro level):

1.) Build Data Table (7 columns that are named {Name, Phone, Address, Distance, Specialty, Reviews, Status)

2.) Do While Loop - We are pulling line item information and allocating them individually into 7 variables that would go in their appropriate column name (vars have same name as column name in data table)

3.) For each line item we would add another row with the 7 vars going into their appropriate columns.

Unfortunately, it doesn’t seem to be working. Any help is much appreciated.

Thanks.


#2

Can you be more specific?

Are you getting any errors

or

values are being assigned to different columns

or

nothing is being inserted?


#3

Apologies…so I am setting it up using ‘Add Data Row’

In the properties panel, in the ‘Input’ field I have it set up like this:

{ vMdName, vDistance, vSpecialty etc…}

However the final output which I put to an csv file only shows the first column (vMDName) being populated.


#4

Your while loop will get all variables for a row in one loop, Correct?

Is your logic similar to below:

Build DataTable will columns ----> dtTable

While (Line <> string.empty)
{
vMdName = line(1).Tostring(); //line is array split column wise from your source
vDistance = line(2).ToString()

AddDataRow
{ vMdName, vDistance, vSpecialty etc…} --> In ArrayRow
dtTable —> in DataTable
}

WriteCSV -----> dtTable


#5

Overall structure is correct but inside while loop is different…similar to this:

1.) Build Data Table
2.) While ‘Object Exists’
- Pull line item info and allocate to variables.
- Add data row (same array row setup as previous post
3.) Write csv (after while loop ends)


#6

Looks fine for me, unless something is missing at “Pull line item info and allocate to variables.”

Attaches is sample for your reference

csvexample.xaml (8.4 KB)


#7

THanks so much!


#8

Were you able to figure out the reason?


#9

HI vvaidya,

Unfortunately this did not work for me.

I know there’s not much context for you in this xaml sequence but maybe u can see where I am coming from and can help out with the data table building.

DOWHileSequence.xaml (67.9 KB)

Inside the sequence called ‘Line Item Content Loop’ is where I am pulling out the values and allocating to their appropriate vars…at the end of this sequence is where I want to add to the datatable.

Hope this makes sense.


How to insert data dynamically in data table
#10

Are you adding only two columns values to datatable in Add Data Row?

I see this : {vMD_Name, vMD_Distance}


#11

Nope its 7 total…I only included two in this sequence to try and prove the concept.

In the Build Data Table activity you can see the column names


#12

Did you check writing those column values to write line and you are able to see the values?


#13

Yep they definitely have values I write all variables into a write line activity tro confirm this…but actually inputting into the ‘Add Data Row’ activity is where the problem is


#14

I see 8 columns, you mentined 7 above


#15

Whoops, apologies.

8 is correct.


#16

Hello, did you get a solution to this? I am also having the same problem, I have build the data table but I want to pass variables into the columns


#17

did you get an answer to this?