The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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 Champions.
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 :)