Creating/Using Queue item for Invoice Processing with Nested Data Table

I am building an invoice processing bot, and I understand how to use the GetQueueItem for adding the key information from the invoice to queue items.

However the invoice also contains a list of the item codes of those that were purchased, and the quantity of that item. In order to update stock on the software this information is also required to be used by the process.

I was wishing to nest a datatable within the queue item in order to simulate the invoice rows, but I am unsure how to push this in Studio up to the orchestrator, and fetches this error

image

Could anyone offer some advice on how to process this information correctly?

hello @LewisHenderson

I couldn’t find any concept regarding nesting datatable or any other datatype into queueitem variable type.
Instead a separate queue could be used for solving this purpose.

Have you tested to serialize the datatable into a JSON string and add it to the queue item? When you retrieve the queue item later you can deserialize the JSON string back to a datatable.

To convert to JSON string:

strJSON = Newtonsoft.Json.JsonConvert.SerializeObject(DT)

Convert JSON to DataTable:

newDT = JsonConvert.DeserializeObject(Of DataTable)(strJSON)
newDT = JsonConvert.DeserializeObject(Of DataTable)(strJSON)

This line is fetching an error, stating that JsonConvert is not declared, have tried Newtonsoft.Jsonconvert as well but also does not declare.

Any idea what the issue could be @ptrobot

Have you installed the Newtonsoft JSON package?

Installed, still encountering this

image

Ok, that’s is strange. Just tested on my computer and it’s working fine. Could you test to restart UiPath Studio and then import the namespace Newtonsoft.Json?

And also noted that you are missing Json in between:
image

It should be Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(strJSON)

But after you have imported the namespace you could skip the “Newtonsoft.Json” completely.

I restarted UiPath and rebuilt the sequence to see if it was an error somewhere else and it has done the trick. Thanks for your debug assistance.

That serialize/de-serialize will do just the trick

Great to you hear that you got it working! :smiley: :+1: