How to write IEnumerable<QueueItem> to DataTable

Hi,

I am trying to store the IEnumerable from my Get Queue Items activity into a data table. What is the simplest way to do this?

Thank you for any help

@justinkxc

Hi @justinkxc

Check the below thread for your reference,

Hope it helps!!

I am using C# i am not sure how this works

Assign Activity:
dtData =

JArray.FromObject(YourGetQueueItemsOut.Select(Function (x) x.SpecificContent).toArray).toObject(Of DataTable)

@justinkxc

JArray.FromObject(YourGetQueueItemsOut.Select(x => x.SpecificContent)).ToObject<DataTable>()

Try this

Okay @justinkxc

Below expression is the C sharp expression,

JArray.FromObject(YourGetQueueItemsOut.Select(x => x.SpecificContent).ToArray()).ToObject<DataTable>()

Hope it helps!!

Hi @justinkxc

- Build DataTable
  Columns: Column1 (String), Column2 (String), Column3 (DateTime)
- Get Queue Items
  Output: queueItems (IEnumerable<QueueItem>)
- For Each item in queueItems
  TypeArgument: UiPath.Core.QueueItem
  
  - Add DataRow
    DataTable: [Your DataTable]
    ArrayRow: { item.SpecificContent("Column1").ToString(), item.SpecificContent("Column2").ToString(), item.SpecificContent("Column3").ToString() }

Hope it helps!!

Thank you all for the help. the C# code works. that was a simple solution thank you again :slight_smile:

1 Like

@justinkxc

Kindly Mark as solution so the loop closes

I hope you find the solution for your query. Make my post Mark as solution to close the loop… @justinkxc

Happy Automation!!

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