How to select all the option in the multipledropdown field by default and also provide "select all" option in dropdown

Certified Associate Developer

Hi All,

i want to know , how to configure the below logic

BY default all the option should be selected. and also in dropdown i can have the option to deselect all /select all along with all the options.

Please help me how i can go about this

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Associate Developer
    in reply to Anitha Dharmalingam

    Well in that case try this code ,this can be a workaround the intended functionality

    a!localVariables(
      local!allOptions: {
        1, 2, 3, 4
      },
    
      local!selectedOptions: local!allOptions, /* Default: all selected */
    
      local!selectAll: true, /* Controls checkbox */
    
      {
        a!checkboxField(
          label: "Select All",
          choiceLabels: {"All"},
          choiceValues: {true},
          value: if(count(local!selectedOptions) = count(local!allOptions), {true}, {}),
          saveInto: {
            a!save(
              local!selectedOptions,
              if(
                or(a!isNullOrEmpty(save!value) , length(save!value) = 0),
                {}, /* Deselect all */
                local!allOptions /* Select all */
              )
            )
          }
        ),
    
        a!multipleDropdownField(
          label: "Options",
          choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4"},
          choiceValues: local!allOptions,
          value: local!selectedOptions,
          saveInto: {
            a!save(local!selectedOptions, save!value)
          }
        )
      }
    )