How to force a text field to accept only numbers following by letter d using ScriptRunner Behavior

Mahdi Challouf
Contributor
April 28, 2024

Dears,

Currently, I'm tasked with creating a text field tailored for estimations within Jira Cloud. This field should exclusively accept numerical values followed by 'd' for days or 'w' for weeks.


The desired format is akin to '1d', '5d', or '1w'. While I've successfully implemented this functionality in Jira Data Center using specific code

def estimationField = getFieldById("customfield_10647")

def estimationValue = estimationField.getValue()

estimationField.SET_DESCRIPTION("(eg, 4d, 1w)")

if(estimationValue !="" && !estimationValue.matches('(^[0-9]*+d')){ estimationField.setError("estimation should be in days") }

else { estimationField.clearError() }

I'm encountering challenges adapting it for Jira Cloud. Any assistance in achieving this goal would be greatly appreciated.

Thank you.

1 answer

1 vote
Nic Brough -Adaptavist-
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.
April 28, 2024

Hi Mahdi,

Where are you stuck on "adapting it for Cloud"?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events