multiselectListbox - select all - unselect all - limit number of selection

Hi,
I created a switch button that select ALL as false status and unselect ALL as true status from a list of multiselect:

It works for select All multiselectListbox1.setValue(formatDataAsObject(multiselectListbox1.data).value)

and not for unselect ALL
multiselectListbox1.setValue([])

Any idea how can I limit the number of selection, for example user can select only 4 elements from the list ?

Hello,

There is no hard way to stop user from select more than 4. However, you can use validation rule.
image

Then you can use .invalid property for any other logic like disable submit.
multi-select

2 Likes

Thanks @lamh_bytecode.io

1 Like