How to upload\consume the bulk data to\from queue

How to upload and get the bulk data (Datatable or other object) to and from a queue in orchestrator ?

Pre-requisite

  1. Studio - Install Uipath.Web.Activities package and import Newtonsoft.Json namespace

  2. Robot - Provision the bot to the orchestrator
  3. Orchestrator - A queue has to be exists in the same orchestrator where robot is provisioned

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:

  1. Serializing the datatable as JSON: Assign String strJson = JSONConvert.SerializeObject(dt)
  2. 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:

  1. Get the item from queue using Get Transaction Item activity and save to (transItem) variable of type UiPath.Core.QueueItem
  2. Assign : strJson =  transItem.SpecificContent("arg1").ToString
  3. Deserialize the strJson back to datatable using Deserialize JSON activity with TypeArgument as Datatable
From Studio 18.4.5 onwards:-

We have an activity Bulk add Queue Item with the UiPath.System.Activities v19.4.0
https://activities.uipath.com/docs/bulk-add-queue-items
Release notes:-
https://activities.uipath.com/docs/release-notes-system#section-uipath-system-activities-v19-4-0

Note: The above steps are applicable to upload/download whole excel data(DataTable) to/from a single TransactionItem.