I have a postal code field and a phone number field that only exists on the jira edit screens of an issue type.
I would like to use regex expression to validate the format of postal code: A1A 1A1 and phone number is: (123) 456-7890
if do not match prompt error to correct format.
is this possible on edit screens (there is no transition screen and the fields do not exist on the create screen)
Hi @Mary Mark ,
If you have the scriptrunner addon it allows you to set up a behaviour that reg-exes a field on the edit screen.
Here is another article where they found a solution that you are looking for I believe: https://community.atlassian.com/t5/App-Central-questions/Use-Behaviour-to-enforce-regex-on-text-custom-field/qaq-p/1482978
best regards
Lisa
Thanks for the find @Lisa Forstberg
I’m wondering does the script apply to all text fields or specific custom fields. I’m not sure where in the script to specify the custom field name or id?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mary! Do you have the scriptrunner addon? I would recommend using the tutorials on their documentation site to get going.
https://docs.adaptavist.com/sr4js/latest/features/behaviours
best of luck
/Lisa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lisa,
I tried for postal code this:
def field = getFieldById(getFieldChanged())
def val = field.getValue() as String
if (!val.matches("^[A-Za-z]\d[A-Za-z] \d[A-Za-z]\d$")) {
field.setError("postal code must be A1A 1A1.")
} else {
field.clearError()
}
but still doesn't work. It shows a little warning and error on ^ --> If (!val.matches line
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.