Scriptrunner Behaviour not dynamic

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 Community Champion Nov 02, 2017

Hello, 

Change the if part to this

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

DropDown.setError("")
}

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

589 views 6 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you