Using Jira Data Center 9.4.15
I have a custom field called "Report PDF URL". I have a workflow transition step where I'd like to validate that the url entered into that custom field contains ".pdf".
I found this previous post:
https://community.atlassian.com/t5/Jira-questions/URL-Validation-for-Free-Text-field/qaq-p/1987373
and the suggested scriptrunner:
cfValues['URL Field Name'] ==~ /^((?:https?:\/\/)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&\/=]*|)$/
...but I'm unclear how to modify this for my use case.
Please help, thanks.
Hi @Jennifer Maurer ,
It looks you are right, our regex validator only supports text fields at the minute. I will feed this back to the team, however in the meantime you can achieve this with the Simple Scripted Validator with the following script:
def value = issue.getCustomFieldValue('Custom Url Field') // This needs to be your field name
def pattern = /.*\.pdf$/
boolean match = value ==~ pattern
return match
Could you give this a go and let me know how you get on?
Kind regards,
Bobby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it looks like the regex validator only works on text fields, this is a url field...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You do not have the Regular Expression Check validator ? It works on my side.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh, this confused me. This question was tagged for Cloud, but @Jennifer Maurer is using DC as mentioned in her question.
I will repost what I linked:
On DC, Scriptrunner's regular expression validator only supports:
https://docs.adaptavist.com/sr4js/latest/features/workflows/validators/regular-expression-validator
You can still do this check, just need to write the script.
Sorry for the confusion!
Kind regards,
Bobby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.