Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Validating custom date time field

Marco Scicluna
Contributor
January 14, 2025

How can I create a validation in the Create screen to restrict users to enter a time between 09:00 and 17:00. I wish to prompt the user if the input is outside of this time window and the issue is not created.

Thank you.

1 answer

1 accepted

0 votes
Answer accepted
Robert DaSilva
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2025 edited

Hi @Marco Scicluna , this should be possible with the "Regular Expression Check" validator available in Jira Cloud by default.

 

This will require you to use a plain text custom field, and a regular expression that reflects the range you're looking to validate.

This regex should work, but please confirm with your own testing:

(([9]|1[0-6])\:[0-5]{1}[0-9]{1})|(17:00)

To break down the regex, largely it's split into two sections:

(([9]|1[0-6])\:([0-5]{1}[0-9]{1}))

and

|(17:00)

 

The first section has the following goals:

  • The first digits that appear in the string are between 9 and 16
  • Following these digits, there is a : symbol
  • After this :, there are two digits totalling between 00 and 59

The second section has the following goal:

  • The string is exactly 17:00

 

 

You should be able to add this validator to the create transition, and this will prevent the issue from being created if this fails.

 

Hope that helps,

Robert

Derek Fields _RightStar_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 14, 2025 edited

@Marco Scicluna @Robert DaSilva - This will validate the date entry, but the user won't receive a prompt that the entry is invalid before the issue is created. 

The easiest way to validate user input before they submit the request is to use a Form rather than the out-of-the-box Request format. You can set the validation regex that @Robert DaSilva suggested in the field on that form. 

Alternatively, you could use an App such as Extension for Jira Service Management or Behaviours - ScriptRunner for Jira Cloud. These will both support pre-submit validators on regular JSM portal screens.

Marco Scicluna
Contributor
January 14, 2025

Hi Robert,

Thank you for your feedback. I included the code you kindly suggested as follows but I am getting an error that the expression is invalid when creating an issue.

Reference to your second suggestion, how would the user invokes the Form?

 

Thank you again for your help.

Screenshot 2025-01-15 at 07.07.43.png

Marco Scicluna
Contributor
January 14, 2025

Hi Derek,

Thank you for your feedback.

How would you invoke a Form through JIRA?

Thank you.

Robert DaSilva
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 17, 2025

Hi @Marco Scicluna , it looks like the Validator you picked was the "Date Compare", you should swap to use the "Regular Expression" validator instead.

 

As for @Derek Fields _RightStar_ 's recommendation, you can instead use the JSM Forms feature as part of Jira Service Management. You should see the option in the Project Settings, listed as "Forms". Here's a quick guide written by Atlassian: https://support.atlassian.com/jira-service-management-cloud/docs/create-or-edit-a-form/

One thing I would recommend is ensuring that you link any of the Forms input fields to regular Jira Custom Fields, so that the inputed data is searchable via Jira Issue Search.

Marco Scicluna
Contributor
January 19, 2025

Thank you for your assistance.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events