How to convert queueitem to datarow

Hi!

Does anyone have an idea on how to convert QueueItem to DataRow in UiPath? I would need to do that since depending on the setup, the process I’m developing either uses or doesn’t use Orchestrator. In such case it makes life a lot easier to handle the transaction items as Datarows in all cases. Any ideas on how to do the conversion?

3 Likes

Please check DataRow Class (System.Data) | Microsoft Learn

What this means is that you can’t build a data row without a data table, so first build your data table (https://activities.uipath.com/docs/build-data-table) and then add an array created with the queue values, something like {QueueItem.SpecificContent(“name”).toString, QueueItem.SpecificContent(“name”).toString} to that data table using Add Data row (https://activities.uipath.com/docs/add-data-row)

PS. The array should go in the ArrayRow property.

1 Like

Thanks for your answer! However, my QueueItem contains around 60 columns… Basically it’s based on an application form containing 60 data entries that need to be transferred elsewhere. So if I understand correctly, your suggestion would require re-typing that QueueItem.SpecificContent -part 60 times, which seems excessive. I’m looking for a more dynamic solution but haven’t come up with any. Any ideas? If not, then I guess I have to do it according to that specification :smiley:

You could try using https://activities.uipath.com/docs/generate-data-table, generating the table using a queue item converted to string, but not really sure if you can do that without writing QueueItem.Specific content 60 times :frowning: .

Ok, thanks Robert :slight_smile: Still, if someone else has solved this issue, I’ll be glad to hear. Until then, I guess this is the best way to do this conversion. I tried also CType conversion from QueueItem to Datarow but apparently it isn’t allowed…

Hello jt92,

I have a similar need as yours where I have to convert queue item to data row , did you find any other solution except using queueitem.SpecificContent

Hi,
I was working on something similar sometime back where I needed to write the contents of QueueItem variable back to datarow of my datatable/excel. I was able to achieve it as below:

For each (field in dummyRow.Table.Columns)
----dummyRow(field.ColumnName)=queueItem.SpecificContent(field.ColumnName)

It works without having a need to write all column values individually.

There might be a better and more efficient way to achieve same using LINQ queries than having to use For Each loop if someone wants to give it a try.

Hope this helps.

Cheers,
CT

1 Like

Hi, @jt92

Sorry for delay, I was searching something and stopped here

Just for reference

I needed to do the same some time ago where the automation requeriments are based some group by conditions (columns values) that I need group by lines from Excel File. So a Excel File that have 10 lines may turn into 7 transaction Items (Then maybe I have a Transaction Item with two or more line of my Excel File Source). All of this because in performer I need to create Purchase Order that may have more than 1 item line.

I was be able to do this uploading data to queue by Key-Value pair (json format) then in performer I rebuilded datatable using this expression:

dt_po = JsonConvert.DeserializeObject(Of DataTable)(in_TransactionItem.SpecificContent(“Content Key”).ToString)

Where Content Key is the key that storage your input datatable in json format

In dispatcher you can upload data converting DataTable to Json Format and assign to String Variable

stringJsonDataTable = JsonConvert.SerializeObject(yourDataTable)

Then just Add Queue Item Activity passing String as argument