Dropdown issue

Hi , Can anyone help on how to achieve this please . Thank you in advance for your help.

a!localVariables(
local!values: { true(), false() },
local!labels: { "Yes", "No" },
local!dropd1: null(),
local!dropd2: null(),
a!columnsLayout(
columns: {
a!columnLayout(
contents: a!dropdownField(
label: "Dropdown 1",
choiceLabels: local!labels,
choiceValues: local!values,
placeholder: "Select a value",
value: local!dropd1,
saveInto: {
local!dropd1,
a!save(
local!dropd2,
a!match(
value: local!dropd1,
whenTrue: fv!value,
then: false(),
default: null()
)
)
}
)
),
a!columnLayout(
contents: a!dropdownField(
disabled: and(local!dropd1, not(local!dropd2)),
label: "Dropdown 2",
choiceLabels: local!labels,
choiceValues: local!values,
placeholder: "Select a value",
value: local!dropd2,
saveInto: { local!dropd2 }
)
)
}
)
)------- This works but 

Hi , For example If i have local!labels: { "Yes", "No" ,"Others", "Not required"} -- If i select dropdown 1 values as yes , in dropdown 2 its should auto fill value to Others and if dropdown value is no , then it should populate value as " yes " on the field . The catch here is even after populating the values the user should still have and option to change the values by selecting any value from dropdown.

 

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer

    hi  ,

    Please try the below code it will help i guess

    a!localVariables(
      local!values: { "Yes", "No" ,"Others", "Not required"},
      local!labels: { "Yes", "No" ,"Others", "Not required"},
      local!dropd1: null(),
      local!dropd2:null(),
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: a!dropdownField(
              label: "Dropdown 1",
              choiceLabels: local!labels,
              choiceValues: local!labels,
              placeholder: "Select a value",
              value: local!dropd1,
              saveInto: {
                local!dropd1,
                a!save(
                  local!dropd2,
                  a!match(
                    value: local!dropd1,
                    equals: local!values[1],
                    then: local!values[3],
                    equals: local!values[2],
                    then: local!values[1],
                    default: null()
                  )
                )
              }
            )
          ),
          a!columnLayout(
            contents: a!dropdownField(
              label: "Dropdown 2",
              choiceLabels: local!labels,
              choiceValues: local!values,
              placeholder: "Select a value",
              value: local!dropd2,
              saveInto: { local!dropd2 },
              disabled: a!isNullOrEmpty(local!dropd1)
            )
          )
        }
      )
    )

  • Thank you very much   it worked . I didn't realize that we could use match . Thanks for the idea.