Skip to main content
Known Participant
Apr 21, 2025 5:39 AM UTC
Solved

Dropdown component choice share choice list

I have two or more dropdown component and I hope that these dropdown components can share one choice list.

For example

I have a list like {choice 1, choice 2, choice 3, choice 4,...}

In dropdown 1 the choice list should be  {choice 1, choice 2, choice 3, choice 4,...}, when I choose choice 1 in this dropdown, the choice list of other dropdown should be  {choice 2, choice 3, choice 4,...},  when I choose choice 2 in dropdown 2, the choice list of other dropdown (expect dropdown 1 and dropdown 2) should be {choice 3, choice 4,...}

Can appian do like this?

manthiramm310118
Participating Frequently
Apr 21, 2025 9:57 AM UTC

Instead of creating 10 different dropdowns, you can dynamically create dropdowns and update the values like the below sample code.

a!localVariables(
  local!labels: {
    "Option 1",
    "Option 2",
    "Option 3",
    "Option 4",
    "Option 5",
    "Option 6",
    "Option 7",
    "Option 8",
    "Option 9",
    "Option 10",
    "Option 11",
    "Option 12"
  },
  local!numberOfDropdown: enumerate(10),
  /* Created the map to store the values */
  local!selectedValue: a!forEach(
    items: local!numberOfDropdown,
    expression: a!map(value: null)
  ),
  a!forEach(
    items: local!numberOfDropdown,
    expression: a!localVariables(
      local!currentLabelAndValues: remove(
        local!labels,
        wherecontains(
          /* retaining the selected option of each dropdown */
          remove(local!selectedValue.value, fv!index),
          local!labels
        )
      ),
      a!dropdownField(
        choiceLabels: local!currentLabelAndValues,
        choiceValues: local!currentLabelAndValues,
        label: "Dropdown - " & fv!index,
        labelPosition: "ABOVE",
        placeholder: "--- Select a Value ---",
        value: index(local!selectedValue.value, fv!index, ""),
        saveInto: local!selectedValue.value[fv!index],
        searchDisplay: "AUTO",
        validations: {}
      )
    )
  )
)

Note: You might need to change the code based on your business requirements.

11 replies

konduruc733182
Inspiring
Apr 21, 2025 5:45 AM UTC

Hello [mention:c175878b6d0741989dcd8272751de6f9:e9ed411860ed4f2ba0265705b8793d05] ,

Yes, can be done in Appian. Could you please elaborate where you would be saving the selected values? Is this going to be a huge set of dropdowns or just a couple of dropdowns with this behavior. 

Known Participant
Apr 21, 2025 5:47 AM UTC

a huge set of dropdowns, meayb 10 or more

konduruc733182
Inspiring
Apr 21, 2025 5:52 AM UTC

a!localVariables(
  local!labels1: {
    "Option 1",
    "Option 2",
    "Option 3",
    "Option 4",
    "Option 5",
    "Option 6",
    "Option 7",
    "Option 8",
    "Option 9",
    "Option 10",
    "Option 11",
    "Option 12"
  },
  local!value1,
  local!labels2: remove(
    local!labels1,
    wherecontains(local!value1, local!labels1)
  ),
  local!value2,
  local!labels3: remove(
    local!labels2,
    wherecontains(local!value2, local!labels2)
  ),
  local!value3,
  {
    a!dropdownField(
      choiceLabels: local!labels1,
      choiceValues: local!labels1,
      label: "Dropdown",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      value: local!value1,
      saveInto: { local!value1 },
      searchDisplay: "AUTO",
      validations: {}
    ),
    a!dropdownField(
      choiceLabels: local!labels2,
      choiceValues: local!labels2,
      label: "Dropdown",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      value: local!value2,
      saveInto: { local!value2 },
      disabled: a!isNullOrEmpty(local!value1),
      searchDisplay: "AUTO",
      validations: {}
    ),
    a!dropdownField(
      choiceLabels: local!labels3,
      choiceValues: local!labels3,
      label: "Dropdown",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      value: local!value3,
      saveInto: { local!value3 },
      disabled: a!isNullOrEmpty(local!value2),
      searchDisplay: "AUTO",
      validations: {}
    )
  }
)

You might want to redo the code a little bit. This is an example of how you can handle.