How to upload and get the bulk data (Datatable or other object) to and from a queue in Orchestrator ?
Pre-requisite:
- Studio - Import Newtonsoft.Json namespace:
- Robot - Provision the bot to the Orchestrator
- Orchestrator - Ensure that a queue exists in the same folder as the user that is provisioning the Robot.
Step by step guide:
To upload a bulk data like an Excel with 50 columns and 1000 rows, there is always a need to create 50 arguments(columns) to the Add Queue Item activity. It has to be hard-coded and needs an eye whenever there it needs a modification. As there is no explicit way of adding a bulk data to queue, following is one of the ways to upload and consume them back:
Adding items to queue:
- Serializing the datatable as JSON: Assign String strJson = JSONConvert.SerializeObject(dt)
- Add strJson in the queue as argument with some name (Say arg1) using Add Queue Item activity
Where dt is a datatable to be uploaded in the queue.
Consuming from queue:
- Get the item from queue using Get Transaction Item activity and save to (transItem) variable of type UiPath.Core.QueueItem
- Assign : strJson = transItem.SpecificContent("arg1").ToString
- Deserialize the strJson back to datatable using Deserialize JSON activity with TypeArgument as Datatable
From Studio 18.4.5 onwards:
An activity Bulk Add Queue Item with the UiPath.System.Activities starting in v19.4.0
Release Notes: Activities
Note: The above steps are applicable to upload/download whole Excel data(DataTable) to / from a single TransactionItem.