Forums

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

Need a ScriptRunner workflow validator to check a custom field.

William _Bill_ Klein
Contributor
September 18, 2023

Hi,
Looking for a ScriptRunner workflow validator for one of my Jira Cloud sites.

  • Have a custom field defined as a short text field
  • Would like to restrict the first 5 characters to be be any upper\lowercase combo of 'prodid' string.  So Prodid, ProdID, ... would all be acceptable.
  • The remaining part of the string can be 1 or more numeric characters.  Examples; Prodid1234, prodid1, ProdID123456789, ...  would all be acceptable.

Prefer to use the ScriptRunner Validator so I can customize the error message.

1 answer

1 vote
Felix Linh
Contributor
September 18, 2023

Hi William, nice to meet you here.
Please use this script to validate the custom field.

def customField = getCustomFieldValue("Your Custom Field Name") if (customField ==~ /^(?i)prodid[0-9]+$/) { return true } else { def errorMessage = "Invalid format. Please ensure that the first 5 characters are a case-insensitive 'prodid' followed by one or more numeric characters." setValidationErrorMessage(errorMessage) return false }

Thanks.

Felix M.

William _Bill_ Klein
Contributor
September 18, 2023

Hi Felix,

Nice to meet you and thank you for the quick reply.  

Solution not working for me.   I tried putting this code into a ScriptRunner Cloud workflow validator extension and see the following:

Screenshot 2023-09-18 190128.png

William _Bill_ Klein
Contributor
September 18, 2023

Guess what I am looking for is something like this:
issue.customfield_10038 == ("/^(?i)prodid[0-9]+$/]")

The above does not work, but how to have the custom field check against a regular expression

Tomas Arguinzones Ruiz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 9, 2025

@Felix Linh works like a charm. Thank you!

Felix Linh
Contributor
July 9, 2025

Sounds good to me!. @Tomas Arguinzones Ruiz  

Felix Linh
Contributor
July 9, 2025

Please let me know if you need my help.  I'm a seasoned full stack developer, I can work perfectly and I will always trying to have the right attitude to improve your product to another level. I'm looking forward to your response.

Thank you,

Felix.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events