Behaviour setError() only showing error message every other time

I have a behaviour created that validates a simple Number custom field to make sure it is between 0 and 100. Here's the code I'm using (as a serverside script for the "Percent" field):

def percent = getFieldByName("Percent")

if(percent.getValue()){
    def value = percent.getValue() as double
    if(value < 0 || value > 100){
        percent.setError("This must be a number between 0-100")
    } else {
        percent.clearError()
    }
} else {
    percent.clearError()
}

The script works.... but only every other time. If I continuously enter random invalid values in that field, I can see the error appear and disappear over and over again. I should mention that when I say "it doesn't work" I mean that the error message doesn't appear. The input box is still outlined in red, and if I try to submit the form I am unable to do so and the error message then appears. So it's a minor bug, but an annoying one. Has anybody else seen this? Do you know how to work around it? Am I doing something wrong in my code? Or is it truly a bug and needs an update to the plugin? @Jamie Echlin [Adaptavist]? Can you confirm?

2 answers

1 accepted

Hi Jordan,

This is a known issue and actually it will be fixed in the next release (hopefully very soon). You can start watching the development issue SRJIRA-2136 for updates. 

regards, Thanos

Thanks for the heads up! Looking forward to the update.

Remove the first  IF-ELSE condition because of this error message appear and disappear again and again

That first if-else statement is there in order to check for null values.... I don't think that's causing the issue. Sounds like it is indeed a bug (according to Thanos' answer). Thanks for trying, though.

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,120 views 13 19
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