Cascade Dropdown

Hello All,

I have a requirement where i have to create two dropdown fields but second dropdown will depend upon first. Suppose user selects one option from the first dropdown then according to that option second dropdown show options. one more thing is that i want second dropdown only appears when user choose option from first dropdown.

Kindly suggest how to achieve this.

Thanks in Advance

  Discussion posts and replies are publicly visible

Parents
  • Hi
    You can achieve this by saving the values to be shown in the second drop-down on the selection of 1st drop-down and show the second one only after the first is selected. 
    Make sure to do a null condition if the option is changed in the first one. Something like this.

    load(
      local!dropdown1: {1,2,3},
      local!value1,
      local!value2,
      local!dropdown2,
      {
      a!dropdownField(
        label: "Dropdown 1",
        placeholderLabel: "Please select",
        choiceLabels: local!dropdown1,
        choiceValues: local!dropdown1,
        value: local!value1,
        saveInto: {
          local!value1,
          a!save(local!value2,NULL),
          if(local!value1=local!dropdown1[1],a!save(local!dropdown2,{4,5,6}),a!save(local!dropdown2,{7,8,9}))
        }
      ),
      a!dropdownField(
        showWhen: not(rule!APN_isBlank(local!value1)),
        label: "Dropdown 2",
        placeholderLabel: "Please select",
        choiceLabels: local!dropdown2,
        choiceValues: local!dropdown2,
        value: local!value2,
        saveInto: local!value2
     )
    })

  • 0
    A Score Level 1
    in reply to ekanshj

    Thanks for replying, if user selects second option or third option he will get same options in second dropdown. how can we configure it dynamically.

  • 0
    A Score Level 2
    in reply to gopalk0002

    yes this has to be dynamic in nature based on selection for that either you have to use database queries where based on your selection it will pass as input and fetch the relevant options or you can create a decision which can be configured as per input and gives out the output.

Reply Children