Behaviors Script to validate field drop down select options

Scott Federman
Contributor
February 8, 2021

I have a single select dropdown field called "How did you hear about AIES? I have a default option that is "Choose from the dropdown". What would the script be that will validate that this field does not have "please choose from the dropdown" selected in this field? 

1 answer

0 votes
PD Sheehan
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.
February 8, 2021

Generally, I'd recommend you just remove that "choose from the dropdown" option, remove your default value and set that field as required. This will let the built-in logic take care of ensuring a field is selected.

But if you really insist on using a script runner script, you can do it with something like this:

def field = getFieldById(getFieldChanged())
field.clearError()
if(field.value == 'Choose from the dropdown'){
field.setError('Please choose from the dropdown')
}

Suggest an answer

Log in or Sign up to answer