Looping DataTable array and using an invoke workflow with it

Hello,

I have a workflow set up, where it reads 4 excel sheets into different datatables, assigns them each a name with .TableName, and I have an array of these 4 datatable variables.

What I want to do, is to loop through every datatable, and invoke another workflow. In that workflow, I need to use the name of the current datatable, and that does not seem to work and I get an error that the referense is not set.

An example is below, where I try to call the TableName from the current datatable, and just put it into a message box, before moving on to the Workflow (the TypeArguement of ā€œForLoopā€ is set as a datatable):

Not sure if I will have issues in the workflow as well. In the second workflow I have an ā€œInā€ Argument set up, called ā€œtableā€ like in the loop, and the values are set up in the ā€œImport Argumentsā€ screen as well, with the argument value being ā€œtableā€.

What should I do to avoid this?

Thank you!

Well,

Even though if you ā€˜writeā€™ the table name in the workflow it is an item in an array.

You might have to convert it the following way

ctype((YourTableItemInArray), System.Data.DataTable)

Also, you might want to consider an object array or list which can be converted in real time like I mentioned above.

Thank you, you put me on the correct path.

What I ended up doing (for anyone else with a similar question), was initiate a new list with an assign activity like so:
DTlist = New List(Of System.Data.DataTable)
DTList, being a variable of System.Collections.Generic.list<System.Data.DataTable> type.

And then I used ā€œAdd To Collectionā€ activity for each table, the collection being the DTlist, item is the name of the table and TypeArgument is DataTable.
There might be a faster way, but for my purposes it is quite reliable.

2 Likes

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