How to limit the number of digits in a custom field

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

Purpose

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 add-on or custom development.

You can utilize a workflow validator with RegEx to achieve it. The step-by-step process is given below:

  1. Go to Project settings > Workflows of the desired project
  2. Find the required workflow and click on the Edit (pencil) icon under the Actions column
  3. Click on the Diagram view and select the required transition (For example, Create transition)
  4. Under Options, click on Validators
  5. Click on the Add validator button, select the Regular Expression Check option, and click the 'Add' button
  6. For Field to validate:, select the text custom field that needs to be validated from the drop-down menu
  7. 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.



Last modified on Jun 13, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.