Ability to input a collection variable in activity

Hi all,

So i’m currently looking to create a generic uploader from excel to queues in orchestrator. In the “Add queue item” activity the ItemInformation field has to be manually set. In my use case i’m looking to have a single file, that you configure with a few assets and then set this to run on any spreadsheet and queue without having to go into studio.

Currently we have to have a separate file per queue/spreadsheet which will result in quite a few processes in the future.

It would be really great if we could input a collection here rather than have to manually amend this per instance of our uploader.

Any thoughts/questions please let me know.

Thanks

1 Like

Here is an idea, why not network with a dedicated network (accessible by robots)
Each launch of a robot, it goes into this directory if there is a new file file to be processed (hotfolder type).
Then you start processing your file.

Hi djunqua,

While that seems like a workaround for another issue i don’t think it’s suitable here.

The issue is that we have created a process to upload data to an orchestrator queue and would like this to have the ability to be configured to run for any spreadsheet without having to touch the process through the studio. Currently this is not possible as the Collection for the activity “Add Queue Item” is manual and does not accept a variable input. There are workarounds but they all require extra changes to be made in the studio for each spreadsheet needing to be run.

If the collection input was a variable input (or manual) we could resolve this as an issue.

Thanks

Hi, maybe I misunderstand your issue, but you can use variables for the “Item information” property and the “QueueName” property of the Add Queue Item activity. And the content of the Item Information can also be a variable. See screenshots below from one of my processes.

image

Hi Christian,

It is indeed very useful to use variables as the value. What i’m really looking to do is set the entire collection as a variable. Therefore we can dynamically generate our item information based on the excel spreadsheets we provide it.

Thanks

1 Like

So normal collections in UiPath (Add to Collection activity) are 1-dimensional arrays. If that is sufficient for you, you just build up the collection with items based on your Excel. You just need to make sure to initialize the collection, so even if some fields remain empty, you don’t get an error, e.g. item(5)=“”

If the data is multi-dimensional, it’s a bit more complicated and I would use a DataTable, which you build based on the data from the Excel. And then similar as with the collection, you indicate row and column by variables.

If you need additional help, it would help to know what the differences are between the Excel sheets and what you want to store in the queue.

You’re saying you would like to have a generic loader process with a json/collection as Input. In this case the input may be dynamic instead of being configured for each process.

1 Like

Hi Badita,

I have evidently done a terrible job at explaining this but yes that is correct. So that you can input a collection with a variable number/name of items.

@Christian_Hennig I use the array technique in my current methods but this doesn’t allow me to vary the number/name of the arguments.

Thanks

Hi @jakelewis18,

Sorry to post on an old thread, but were you able to find a resolution for this? I have multiple excel worksheets with unknown number of columns and I wanted to add them to queues, row by row. I believe my requirement is similar to yours and it would extremely helpful to know what you did for achieving your objective.

Thanks

Hi,

Our team has moved away from using queues currently, as such we didn’t find a solution.

Our one solution was to identify each spreadsheet by a unique identifier (name or a specific header combination) and then create an add to queue activity for each of these in a switch.

Not ideal but this does work.

Thanks

Thanks @jakelewis18 for your help.

The scenario is to add an excel row with unknown number of columns, as a queue item. I am not sure how would you add a switch if the number of columns are unknown, and what data type would send the whole row data (since we are unable to send datarows or arraylist as arguments in add to queue collection activity). In case you have some more pointers, do let me know.

Thanks again!

hi @PrakharR

I’ve had a think and one way to do this would be to use a loop that reads the whole row and then concatenates this row into a single variable with a known separator.

For example you could have a spreadsheet with 4 columns (ID,StockAmount,Itemname,ItemValue) with values 23,563,Apples,1

and then read this as:

while( header is not blank)
string = string & “#” & rowitem

Which would end up with a string looking like “23#563#apples#1”.

You could then use a single “Add Queue item” activity with the single string variable to upload.

The only issue with this is that you would then have to split this by your separator at the other end.

Hope that makes sense.

Hey @jakelewis18,

That sure makes sense!. And it would work.

However, For the benefit of the lazy people like me :stuck_out_tongue: , I found a workaround without having to iterate over all the row items. I was able to parse the information of each datarow as a JSON string and then send them over in Add Queue Activity.

Here is a snippet of my algorithm -

  • Read excel sheet as a datatable
  • For each row in data table
    • Convert the row into JSON string
      using assign ConvertedRowVariable = JSONConvert.SerializeObject(row)
      [For this function, you have to import Newtonsoft namespace first by imports > newtonsoft.json].

    • Deserialise json string using deserialise activity(You may have to import web services package for this). Assign it to DeserializedJsonVar

    • Assign using assign activity RowItemJson = DeserialisedJsonVar(“Table”)(sheetContents.Rows.IndexOf(row)).ToString

    • Send RowItemJson as an argument in Add to Queue Activity

We can extract the Json string when getting the queue item,deserialise and get the required key value data. Since my excel items were variable assignments, json format helped a lot.

This way I was able to send dynamic excel(indefinite rows and columns) as queue items.

Thanks for your efforts!
Hope this would be helpful for someone in future!

1 Like

Hi Prakhar ,

How you extracted the data from queue in your case ? As now we have sent each data row as Json string into the queue , can you share the detail steps for extraction ?
@PrakharR @badita

Thanks
Ankit

@ankit3091

Hi Ankit,

I am using deserialise JSON activity to extract items from Queue

  1. Assign jsonString = QueueItem.SpecificContent(“KeyForData”).ToString
  2. Deserialise jsonString (specify output property as jsoncontent)
  3. Assign variable1 = jsoncontent(“key1”).toString
  4. Assign Variable2 = jsoncontent(“key2”).toString
    …So on

Attaching the workflow below for easy reference.
Hope this resolves your queries!

Cheers!

  • Prakhar

Hello,

Could you please attach your XML file. Would be much more easier to understand.

Hi @diksha_sawant

Here is my xaml file. I am also attaching project.json with the requisite dependencies. This project has been migrated to 2018.3.0 Beta version of uipath.

addtoqueue.xaml (43.2 KB)

project.json (756 Bytes)

This is for packaging the data and sending it to the queue as a JSON object.

Happy to help further if required

Prakhar

Hi, It would be really great if you could extend QueueItem parameters to more than just a “String” type.
e.g. Int,Bool,Collections,DataTables
In current scenario, it limits the use of Queue to a great extent.