Skip to main content
January 17, 2025
Question

Dropdown issue

  • January 17, 2025
  • 2 replies
  • 0 views

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.

 

    2 replies

    jayaprakashr0001
    January 17, 2025

    hi [mention:213d84d7e74a4c32847efd6906fcf281:e9ed411860ed4f2ba0265705b8793d05] ,

    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)
            )
          )
        }
      )
    )

    January 17, 2025

    Thank you very much [mention:44bed26f1d96482687e4003414c7d8ec:e9ed411860ed4f2ba0265705b8793d05]  it worked . I didn't realize that we could use match . Thanks for the idea.