How to limit the number of digits in a custom field
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
As an administrator, you may want to limit the number of digits that can be entered in a custom field for an issue type.
Environment
Jira Cloud / Jira Service Management Cloud
Solution
This solution only works for
text fields
and
not number fields
. If you require a solution for a number field, you may need to consider a third-party
or custom development.
You can utilize a workflow validator with RegEx to achieve it. The step-by-step process is given below:
Go to Project settings > Workflows of the desired project
Find the required workflow and click on the Edit (pencil) icon under the Actions column
Click on the Diagram view and select the required transition (For example, Create transition)
Under Options, clickonValidators
Click on the Add validator button, select theRegular Expression Check option, and click the 'Add' button
For Field to validate:, select the text custom field that needs to be validated from the drop-down menu
For Regular expression: column, add the expression in the format [Range of numbers]{Number of digits}. For example, to limit the number of digits in the custom field to 5 (i.e. the numbers varying from 00000-99999), use [0-9]{5}

8. Click the 'Add' button
9. Click on Publish Draft > Publish to save the changes to the workflow. If you want, you can save a backup copy of the current workflow by selecting Yes in Save a backup copy?
Adding the above sample regular expression to the workflow validator will limit the number of digits entered into the custom field to 5. If a user enters a number that is more/less than 5 digits to this custom field, they will receive an error message and be prompted to enter a valid number.

For more information about workflow, please visit Configure advanced issue workflows.
Was this helpful?