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?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Senior Developer
    in reply to edwardc8281

    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.

  • Thanks Konduru, I have tried this way, but if I have a huge dropdowns, like I have 10 dropdown component, I should creat 10 labels and values, right? What I want is use a more common or easy way to imply my require.

  • I have also tried this way, but I failed.

    a!localVariables(
      local!choiceLabels: {
        "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!choiceValues: { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 },
      local!checkedValue: a!refreshVariable(
        value: { ri!q1Choice, ri!q2Choice },
        refreshAlways: true
      ),
      local!uncheckedValue: a!refreshVariable(
        value: symmetricdifference(local!choiceValues, local!checkedValue),
        refreshAlways: true
      ),
      {
        a!dropdownField(
          choiceLabels: local!uncheckedValue,
          choiceValues: local!uncheckedValue,
          label: "Dropdown",
          labelPosition: "ABOVE",
          placeholder: "--- Select a Value ---",
          value: ri!q1Choice,
          saveInto: ri!q1Choice,
          searchDisplay: "AUTO",
          validations: {}
        ),
        a!dropdownField(
          choiceLabels: local!uncheckedValue,
          choiceValues: local!uncheckedValue,
          label: "Dropdown",
          labelPosition: "ABOVE",
          placeholder: "--- Select a Value ---",
          value: ri!q2Choice,
          saveInto: ri!q2Choice,
          searchDisplay: "AUTO",
          validations: {}
        )
      }
    )

  • 0
    Certified Senior Developer
    in reply to edwardc8281

    Create an expression rule to perform the logic and reuse based on the input value.

  • 0
    Certified Lead Developer
    in reply to edwardc8281

    Did you consider to just use a multi dropdown field? I mean, by this logic, you can select each item only once.

  • Thanks, but the multi dropdown field is not suit for our business. What I want is the choice in one dropdown will impact on the choices value of other dropdown component.

  • 0
    Certified Lead Developer
    in reply to edwardc8281

    OK, but I assume that you will then use different choices for the other dropdowns. And this is different from the issue in this discussion.

  • +1
    Certified Senior Developer
    in reply to edwardc8281

    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.