Scriptrunner Behaviour not dynamic

Bob November 2, 2017

Apologies I didn't know how best to work the title, hopefully I can explain better below: 

 Essentially I have some code below: 

def dropDown = getFieldById("customfield_10052")

log.debug("dropdown value" + dropDown.getValue())

if (dropDown.getValue() == "Art") {
dropDown.setError("cannot choose art here")
} else {


}

 I am essentially checking a custom field for if its value is Art and choosing to display an error message if it is. 

My problem is, if the user ever simply selects Art even with the intention of later selecting something else, the error message shows and wont go away, even if the user selects a different value. 

 

Is there something I could do within the else to remove the error message/ re initialize the form? 

 

Many thanks for the help. 

1 answer

1 vote
Alexey Matveev
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.
November 2, 2017

Hello, 

Change the if part to this

if (dropDown.getValue() == "Art") {
dropDown.setError("cannot choose art here")
} else {

DropDown.setError("")
}
Bob November 3, 2017

Hi Alexey, 

 

Thank you so much, that worked.I should say I also discovered the method: 

.clearError("")

 You absolutely pointed me in the direction for that, many thanks!

Suggest an answer

Log in or Sign up to answer