Convert from Config setting to array

Hello folks, UiPath beginner here.

In my Config.xlsx file I have declared a values for my queue:

Name: arrQueueItems
Value: {“cat”, “dog”}

In Studio I’m trying to assign Config(“arrQueueItems”) to QueueItems and add QueueItems to the workqueue. What I tried so far is using DirectCast and CType, without success.

QueueItems is declared as a variable of type String.

QueueItems = DirectCast(Config(“arrQueueItems”),String())
Error: Unable to cast object of type ‘System.String’ to type ‘System.String

Any help would be greatly appreciated.

we cannot bypass compilation, so the string is not casted to a string array

We can do - using a string in the config and

  • split it with the split method
  • Defining a serialized JSON String of the array and deserailize it


You cannot directly do that

assign the value in config as cat,dog

and in the studio use as QueueItems = Config("arrQueueItems").ToString.Split({","},StringSplitOptions.None)


You can split the items with comma before assigning it to QueueItems. Try this:
QueueItems = DirectCast(Config(“arrQueueItems”).split(","c),String())

1 Like

Try entering that data in config in this format:

later after retrieving you can use a Split function
workItems= config(“arrQueueItems”).toString.Split({","c})

Here workItems would be of Datatype String

That way you can loop through and process your work items…


Happy Automation!

1 Like

Thank you for the prompt replies.
I followed the advice of @Anil_G - the items are added successfully to the work queue!

However, what interests me now is why the log message activity prints out the QueueItems to the console as System.String and not simpy cat,dog…

Thanks a lot for the support.

1 Like


If you directly give the variable name it would print the type of the variable

For printing data you can convert back like string.Join(",",queueitems)

Glad your issue is resolved. Happy Automation


1 Like

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