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 Reply Children
  • 0
    Certified Lead Developer
    in reply to Marco

    You didn't understand what I mentioned I am saying based on your needs you can either hide the drop down (Note: this is considering they are seeing read only version form) or don't show the value for that field.

    Also, Note the best practice to show dropdown values in read only form is using text field. see the sample example

    a!localVariables(
      local!loggedUserPermissionValues: {1,2},
      local!selectedValue: 3,
      local!readOnly: true,
      {
        a!textField(
          label: "Any Label",
          showWhen: local!readOnly,
          value: if(
            contains(local!loggedUserPermissionValues, local!selectedValue),
            local!selectedValue,
            /*You can provide any default value here like N/A, -, dont have permisson to vise this value*/
            "N/A"
          ),
          readOnly: local!readOnly
        ),
        a!dropdownField(
          label: "Any Label",
          showWhen: not(local!readOnly),
          choiceLabels: {1,2,3},
          choiceValues: {1,2,3},
          value: local!selectedValue,
          saveInto: {
            local!selectedValue
          }
        )
      }
    )