Cascading dropdown in new forms activities

Hi,

Turning to the forum for the first time. I hope that you guys can help me.

I am using the newest version of studio and form.activities 23.10.5

I have a dropdown that is the parent to another dropdown. So basically I want to populate the second dropdown depending on the selection in the first one.

To begin with, I have it working, almost…

I have a list which is the input to the first dropdown.
The second dropdown lies within a dictionary where the “Key” is the value from dropdown 1. And the values is a list of strings.
This value updates upon selection in dropdown 1, so no choices to start with.

There are, as far as I understand, several ways of doing this.
My first approach was to use the new event triggers to the first dropdown, so that when a selection was made in dropdown 1, it triggered a workflow that then returns a list from my dictionary based on the key (selection).

It worked fine aside from one thing:
The values from the second dropdown does not reset upon changing to another value in dropdown 1. So when I change the selection in dropdown 1, the values that is associated with the first selection still remains.
Meaning that you can choose from an option in dropdown 2 that is not associated with that value(key).

So the question is, how do I make it reset the values when I change option in dropdown 1?

Prior to the new forms version, there also seems to be options to pass the entire dictionary to the forms object. And if you name the in-arguments correctly like “_parent” and so on. This should automatically make it so that the dropdowns are related. But that does not seem to be the case in the new version?
Correct me if I’m wrong.

Really appreciate all the help I can get

Best regards

Hi @Kempe_William

if you are the latest version of forms activities, then you need to create form trigger event for when the dropdown1 values changes. and then in that logic to set the values for the second dropdown.

Hey @Kempe_William ,

For updating Dropdown2 based on the selected value of Dropdown1, you can use the SelectedIndexChanged event of Dropdown1.

I’m sorry that I wasn’t clear enough.
That is what I am currently using, and the second dropdown is actually populating with the correct values.

This is the scenario:
I have made a selection in dropdown 1, lets say I select “Option1”. And then selected a value related to that in dropdown 2, lets say “Option1 child”.

Now, I change the selection in dropdown 1 to “Option2”
The value “Options1 child” from dropdown 2 still remains chosen in that dropdown.

So what I want to achieve is that dropdown2 options is reset upon selection in dropdown 1. And also that any current selection in dropdown 2 is removed.

Best regards

Ok, thanks.
Do you know how to reset values in a dropdown, and also clear any eventual selection?

Best regards

Hey @Kempe_William ,

You can try this,

->Create a new Sequence in UiPath Studio.

->Add an Assign activity to initialize a dictionary variable i.e “DropdownOptionsDictionary”

DropdownOptionsDictionary = New Dictionary(Of String, List(Of String))()
DropdownOptionsDictionary.Add(“Option 1”, New List(Of String) From {“Option 1-1”, “Option 1-2”, “Option 1-3”})
DropdownOptionsDictionary.Add(“Option 2”, New List(Of String) From {“Option 2-1”, “Option 2-2”})
DropdownOptionsDictionary.Add(“Option 3”, New List(Of String) From {“Option 3-1”, “Option 3-2”, “Option 3-3”, “Option 3-4”})

->Use an Assign activity to initialize empty list:

dropdown2Options = New List(Of String)()

->Use Forms activity.

->In the Properties panel of the Forms activity, set the FormTitle to “Dropdown”.

->Click on the “Edit Form” button to design the form.

->In the form designer, drag and drop two dropdown controls onto the form. Name them Dropdown1 and Dropdown2 and close the form designer.

->Use an Event Handler activity
In the properties panel set these values:

  • Event: Dropdown1
  • Handler: OnValueChanged
  • HandlerArguments: sender, e

->Use an Assign activity inside Event Handler Activity:

dropdown2Options = DropdownOptionsDictionary(Dropdown1.SelectedOption)

->Add a Show Form activity after the Event Handler activity to display the form.

Hope it helps,
HAPPY AUTOMATION!!

Just in case someone else stumbles upon this.
You can’t, as of yet anyway, set this in the Edit section. But you can edit the JSON for the dropdown to have this behavior:

Change the “clearOnRefresh” option to true, like this:
image

And also make sure that it refreshed as needed, in my case “RefreshOn”: “projects_dropdown”

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