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

This widget could not be displayed.
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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

71 views 1 0
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