How to limit Number Field to a range of natural numbers (with Script Runner)


I am looking for a way to limit the range of a number field to a certain range of natural numbers. This should always apply and not only in a certain workflow step. I tried to add Javascript to the description as described here. But I guess I am lacking of some important details. 

I thought of using Behaviors provided by Script Runner but also lacking of the implementation details. Perhaps someone has some hints or even a detailed description of how to do it.



1 answer

0 votes


You need to create a behavour. In the field part of the behavour add your customfield. Then push create serverside script button. I am not sure that I understand correctly your required condition but the script will be like the following:

def cs = getFieldByName("CustomFieldNAme")

if (cs.getValue().toString().length() < 2) {
  cs.setError("Hello error")
} else {

You can read more about behavours here:

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


125 views 0 3
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