activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

Workflow Activities

上次更新日期 2025年8月27日

Conditional Dropdowns

Conditional dropdowns enable you to select an option from the dropdown, based on a previous selection made in another form component.

For example, if you select a specific state from a dropdown list, the conditioned dropdown displays the cities in that state.

Tutorial

To use this feature:

  1. Create a parent dropdown, by defining a workflow variable of type List<String> or Dictionary<String, String>. For example, stateList.
  2. Create a child dropdown, by defining a workflow variable of type Dictionary<String, List<String>> or Dictionary<String, Dictionary<String, String>>. For example, cityStateMap.


  3. Drag and drop the Invoke Code activity into the workflow sequence.
  4. Click Edit Arguments and add the previously created variables as In/Out arguments. Click OK.



  5. Click Edit Code. Enter the code to initialize the data and populate the dropdowns with data. For example, the following code snippet initializes the dropdowns (stateList and cityStateMap) and adds items to them.
    // initialize the parent dropdown
    stateList = new List<string>();
    // add items to the parent dropdown
    stateList.Add("HP");
    stateList.Add("Punjab");
    // initialize the child dropdown
    cityStateMap = new Dictionary<string,List<string>>();
    // add items to the HP-child dropdown
    cityStateMap.Add("HP",new List<string>());
    cityStateMap["HP"].Add("Shimla");
    cityStateMap["HP"].Add("Solan");
    cityStateMap["HP"].Add("Hamirpur");
    // add items to the Punjab-child dropdown
    cityStateMap.Add("Punjab", new List<string>());
    cityStateMap["Punjab"].Add("Chandigarh");
    cityStateMap["Punjab"].Add("Patiala");
    cityStateMap["Punjab"].Add("Jalandhar");// initialize the parent dropdown
    stateList = new List<string>();
    // add items to the parent dropdown
    stateList.Add("HP");
    stateList.Add("Punjab");
    // initialize the child dropdown
    cityStateMap = new Dictionary<string,List<string>>();
    // add items to the HP-child dropdown
    cityStateMap.Add("HP",new List<string>());
    cityStateMap["HP"].Add("Shimla");
    cityStateMap["HP"].Add("Solan");
    cityStateMap["HP"].Add("Hamirpur");
    // add items to the Punjab-child dropdown
    cityStateMap.Add("Punjab", new List<string>());
    cityStateMap["Punjab"].Add("Chandigarh");
    cityStateMap["Punjab"].Add("Patiala");
    cityStateMap["Punjab"].Add("Jalandhar");
  6. Drag and drop the Create Form activity.
  7. Store the user dropdown selection into workflow variables. For example:

    • cityListSelected, of type List<String>—stores the list corresponding to the selected state.
    • selectedState, of type String—stores the selected state.
    • selectedCity, of type String—stores the selected city.
  8. Open the FormFieldsCollection window from the activity Properties panel.
  9. To define the dropdown fields in the form:

    • Define the dropdown fields. The Name you set is used for data binding (see Dropdown Component > Field Key tab > Property name).
    • Additionally, define the dropdown lists by appending _dropdown to the dropdown field name.
  10. In the Value column, set the user selection as follows:

    • For the parent dropdown list, use the list defined at Step 1.
    • For the child dropdown list, use the variable stored at Step 7.
    • For the parent dropdown field, use the variable stored at Step 7.
    • For the child dropdown field, use the variable stored at Step 7.



  11. Click OK.

Sample Workflow

To check the complete workflow or to have a future reference, download the XAML example

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2025 UiPath。保留所有权利。