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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,338 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot