Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to restrict existing number field to accept only integers

I have created "Number of Team Members" custom field. The acceptance criteria for this field is value should be integer. The number field is accept float value which is not acceptable. 

I am using scriptRunner in case script is required.

2 answers

Hello @Reshma Patel 

 

Welcome to the community !!

 

Yes, you can apply acceptance criteria for the integer field (Custom Field). You can use the Unique Regex Custom Field macro/plugin in your jira instance. By using this you can restrict the entered values as per your business requirements.

Unique Regex Custom Field 

 

Thanks
Prashant Sultania

Note: Upvote, Like or Accept Answer if it resolves your query.

Is it possible to add validator ?

We don't use plugin

Hello @Reshma Patel 

Yes, it is possible to add the Validator using ScriptRunner. So, you have to use custom_field_ID or Custom Field name in your scriptrunner. 

I am sharing the scriptrunner documentation on "How to use the custom field as the validator in the code". I Hope, this document will help you. 

scripted validators tutorial 

 

Thanks
Prashant Sultania

Note: Upvote, Like or Accept Answer if it resolves your query.

Hi @Reshma Patel  It's very simple to implement using Script Runner Validator. 

Kindly use validator "Simple scripted validator" and apply below condition :-

 

cfValues['CA Ticket#'] ==~ /^[0-9]*$/    

Kindly replace CA Ticket# with your number field or text field.

^[0-9]*$ :- Allow only Integers

^[0-9]+$|^$ :- Allow integers and blank space

Only Interger .PNG

 

Hope it works for you! 

Let me know the result!

 

Thanks

You can test regex code here :- https://regex101.com/

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you