How to deal with changing dropdown values

Certified Senior Developer

I have a dropdown component and I want certain values to be available for choice based on the security groups of the user. For example someone who is only in group A might be able to choose 1, 2 or 3 from a dropdown, someone in group B might be able to choose 4, 5 and 6 from the dropdown and someone who is in both groups would be able to choose all 6 options. Changing the dropdown labels/values based on group is not a big deal to do, however, since the dropdown only allows values to exist that are within the currently available list of labels/values, if group A chooses 1 and someone in group B looks at the form, the 1 will be invalid and break the interface. What would be a good way to get around this issue? 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi if your issue is just for the dropdown error you can use contains in the values

     

    a!localVariables(
      local!selectedValue: 7,
      local!choiceLabels: { 1, 2, 3, 4, 5 },
      {
        a!dropdownField(
          label: "Any Label",
          placeholder: "--Select a value--",
          choiceLabels: local!choiceLabels,
          choiceValues: local!choiceLabels,
          value: if(
            contains(local!choiceLabels, local!selectedValue),
            local!selectedValue,
            null
          ),
          saveInto: { local!selectedValue }
        )
      }
    )

Reply
  • 0
    Certified Lead Developer

    Hi if your issue is just for the dropdown error you can use contains in the values

     

    a!localVariables(
      local!selectedValue: 7,
      local!choiceLabels: { 1, 2, 3, 4, 5 },
      {
        a!dropdownField(
          label: "Any Label",
          placeholder: "--Select a value--",
          choiceLabels: local!choiceLabels,
          choiceValues: local!choiceLabels,
          value: if(
            contains(local!choiceLabels, local!selectedValue),
            local!selectedValue,
            null
          ),
          saveInto: { local!selectedValue }
        )
      }
    )

Children
No Data