Skip to main content
arulk0002
Inspiring
Mar 23, 2022 7:21 AM UTC
Question

Multi Drop Down Validation

Hi Friends,

Please look at the screenshot. There is a two rows. In that two rows should validate when the two rows are equal. So what i am planning in the "Department" section. When i used "Corporate" in the dropdown then it should not come in the second row. Please share your thoughts.

3 replies

sunilnaikb0002
Inspiring
Mar 23, 2022 11:44 AM UTC

You can conditionally manage the choice labels in the second dropdown based on the value selected at the first dropdown. 
can you share the code of the dropdown components, so that the community could get better insight of the use case.

sunilnaikb0002
Inspiring
Mar 23, 2022 12:15 PM UTC

a!localVariables(
  local!savedValueIndex,
  local!firstDropdownSavedValue,
  local!secondDropdownSavedValue,
  local!choiceLabels1: {
    "Corporate",
    "Engineer",
  },
  local!choiceValues1: { 1, 2 },
  local!choiceLabels2: {
    "Corporate",
    "Engineer",
  },
  local!choiceValues2: { 1, 2},
  {
    a!dropdownField(
      label: "Dropdown",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      choiceLabels: local!choiceLabels1,
      choiceValues: local!choiceValues1,
      value: local!firstDropdownSavedValue,
      saveInto: {
        a!save(local!savedValueIndex, index(local!choiceValues1, save!value, null)),
        a!save(local!firstDropdownSavedValue, save!value)
      },
      searchDisplay: "AUTO",
      validations: {}
    ),
    a!dropdownField(
      label: "Dropdown",
      labelPosition: "ABOVE",
      placeholder: "--- Select a Value ---",
      choiceLabels: if(
        a!isNullOrEmpty(local!savedValueIndex),
        local!choiceLabels2,
        remove(local!choiceLabels2, local!savedValueIndex)
      ),
      choiceValues: if(
        a!isNullOrEmpty(local!savedValueIndex),
        local!choiceValues2,
        remove(local!choiceValues2, local!savedValueIndex)
      ),
      saveInto: {
        a!save(local!secondDropdownSavedValue, save!value)
      },
      searchDisplay: "AUTO",
      validations: {},
      value: local!secondDropdownSavedValue
    )
  }
)

Please refer the code to figure out the logic to conditionally manage the choice labels and values.

harshitb6843
Brainy
Mar 23, 2022 12:35 PM UTC

Hi there,

You can add a validation when a single value has been selected more than once. You can use wherecontains function and use it on the CDT/Dict field. If it returns more than one item, then you could show a validation.