How to restrict existing number field to accept only integers

RSP July 20, 2021

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

1 accepted

0 votes
Answer accepted
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2021

Hi @RSP  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

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 20, 2021

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

0 votes
Prashant Sultania
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 20, 2021

Hello @RSP 

 

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.

RSP July 20, 2021

Is it possible to add validator ?

We don't use plugin

Prashant Sultania
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 20, 2021

Hello @RSP 

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.

Suggest an answer

Log in or Sign up to answer