Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can we have a behavior script to make user 'select only one value' in Multi select field

Kiranped March 12, 2021

Can we have a behavior script to make the user 'select only one value' in the Multi-select field?

1 answer

1 vote
Helmy Ibrahim _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 12, 2021

Hi Kiranped,

Yes, you can. The multi-select field will return an ArrayList of Strings when you call the getValue method on its FormField.

Then, you can check the size of the array:

def multiSelect = getFieldById(getFieldChanged())
def multiSelectValue = multiSelect.getValue() as ArrayList

if (multiSelectValue.size() > 1) {
multiSelect.setError("Please select only 1 value")
} else {
multiSelect.clearError()
}

Hope this helps :)

Suggest an answer

Log in or Sign up to answer