Choosing a single string from an array of strings with dropdown list in Assign Activity

This feature is nowhere near available in UiPath which really sucks a lot. Suppose I have an array variable called arrcolor = {“Blue”,“Green”,“Yellow”,“Orange”} with System.String type. I create another variable called ‘color’ with a regular string. In Assign Activity, I specify color = arrcolor(0). That would choose the first choice which is ‘Blue’ in this case. But what if I have 30 different colors set in my array and I’d like to browse for what options I have and be able to quickly select from a dropdown list? This don’t seem possible unless one of the following two cases found below is done, however, I don’t want to do any of those as each has its own drawbacks.

NOTES:

1- I don’t want to include any input dialogs although this could be done because I have many variables apart from color and I don’t want to manually have to set every option every single time I run the script and second because I want to loop the sequence multiple times without any user interaction.

2- I don’t want to create variables for every value ex: Blue = “Blue” / Green = "Green / Yellow = "Yellow etc… because I have a big project and when I’m creating lots of variables, I am noticing that scrolling up and down and opening my project is taking too long to open which is not ideal at all and lagging happens all the time which gets on my nerves. And this is not how variables were intended to work.

So, bottom line, both of these options are not actually of good use for my requirements, but if no solution is provided, I will be forced to stick to option 2 which I’m currently using. What I want is to not only to be able to pick an option from an array of strings, but most importantly be able to generate a dropdown list to view what options I have.

Any help would be much appreciated.

1 Like

Hey @private_matter

You have an array and you are trying to assign a particular array element to that variable.

Sorry I’m not getting it. Could you please explain on the outcome please…

What are you looking to achieve here ?

#nK

Hi @private_matter ,

What i understood is, you want to select multiple option in dropdown list but also you want to make sure the list have that options, is that correct ?

If you can attach some screenshot as input and output it will easier to understand this issue.

Thanks

1 Like

Hi, @ermanoj3101 @Nithinkrishna,

Please view the example screenshot below. I click on the arrow and a dropdown list is automatically generated whereby I can quickly select any variable string I want without the need to type any value. I did the example for the Year which is easy, but I have many other variables which are not possible to memorize. So, I need to have a list of options that I can view and select.

This is currently only possible creating by creating variables and assigning the default VB expression a string value, however that is not so convenient especially when you have lots of values. This cannot be achieved using the system.string to get a dropdown like in the example. Hope this clears things out.

1 Like

Hey @private_matter

Why don’t you please try dictionary collection.

Thanks
#Nk

Hey @Nithinkrishna

I don’t know how to do that. Can you show an example?

1 Like

Hi @private_matter ,

You can also create one template.
And then read it and store it in Dictionary in the same way we do for Config file.

This approach will be dynamic, if in future you want to add new value then just add it in excel file

1 Like

This is perfect @ermanoj3101

Could you please try this @private_matter

1 Like

@ermanoj3101

I don’t like to use external sheets like excel. I prefer if the dictionary is stored within my .xaml file.

1 Like

You can do that also but it will not be dynamic, in future if you need to add some values you have to go to code and then publish package again.

It’s your choice , then use dictionary.

Thanks.

1 Like

Hey @private_matter

Please find this workaround below…

PFA - Dictionary.zip (2.1 KB)

You can even use new Date(01,01,2016).Year This may not be cool but just another thing.

Thanks
#nK

@private_matter

What is the type of year variable in your scenario? Can you explain how did you add the dropdown option in assign

@Nithinkrishna ,

I have downloaded your example but this does not populate a dropdown list in any form or shape as I wanted. The value only says ‘yearDictionary(2021)’

I need a list of options whereby when i click on the activity I get a dropdown list just like when you come to add properties, classes, namespaces, keywords etc… when hitting the spacebar key. That’s not what I was looking for.

1 Like

It’s a sting variable. not int32.

1 Like

@kumar.varun2
see the screenshot above I attached and you’ll understand how. basically, I add a variable of type string and i add the default expression something similar to what the variable’s name is or it could be the same, and then in the assign value i can declare the variable name.

1 Like

@private_matter

Can you share a sample workflow xaml file.

Tried to replicate your scenario but there is no dropdown list or the arrow

@kumar.varun2

Yes there is. see screenshot.

2021-07-28_184134

the dropdown won’t appear if you remove a previous value and attempt to directly type a variable. you must first clear it completely, then press enter (important), then when you click again and type a few first letters, the variables should automatically appear. see this video for more clarity: Microsoft OneDrive - Access files anywhere. Create docs with free Office Online. cheers (:slight_smile:

1 Like

I understood your requirement @private_matter

For this you need to build Enum in a class library and then just install the package in UiPath.

Thanks
#nK

@Nithinkrishna

can you provide an example or steps on how to do this?

1 Like

@private_matter

It is IntelliPrompt that you are talking about. The shortcut for this is ctrl+space.

or right click and click on show intelliprompt

It shows the list of all variables, methods, classes etc…

so if you have variable already declared it will show in the list (intelliprompt)