Forums

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

URL Validation for Free Text field

Madhu Reddy
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.
March 30, 2022

Hello, We have a free text field on which we are planning to add the URLs as there is a Character Limitation for Jira URL fields.

Can we add some workflow validations, conditions which will check for a proper URL which starts with 'https://' and contains 'Sharepoint' in it. 

We have JMWE and Scriptrunner plugins added to our site. 

 

Thanks in Advance

Madhu

2 answers

2 accepted

0 votes
Answer accepted
David Fischer
Community Champion
March 30, 2022

Hi @Madhu Reddy 

using a Scripted (Groovy) Validator (JMWE app), you can use a very similar script:

issue.get("text field") ==~ /^https\:\/\/\w+(-my|-admin){0,1}\.sharepoint\.com((\/\w+[_\-\.']{0,}\w+){0,}[^\.](\w+[-_'\d]{0,})){0,}$/
Madhu Reddy
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.
March 30, 2022

Hi @David Fischer First of All, Thanks for the response.

Tried the script suggested above, getting the validation error that please enter the valid url.

Attached the screenshots for your reference.

Suggested Script.pngURL added.png

Please have a look and correct me if I was wrong, Thanks.

Madhu

David Fischer
Community Champion
March 30, 2022

I actually reused Vikrant's regex, it doesn't really match your URLs.

Try this:

issue.get("text field") ==~ /^https\:\/\/\w+(-my|-admin){0,1}\.sharepoint\.com\/.*$/
Like Madhu Reddy likes this
Madhu Reddy
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.
March 30, 2022

This code worked for me @David Fischer  Thanks a lot for your help

0 votes
Answer accepted
Vikrant Yadav
Community Champion
March 30, 2022

Hi @Madhu Reddy   Try below Code, it should work :- 

 Apply ScriptRunner :-  Simple Scripted Validator

 

cfValues['URL Field Name'] ==~ /^((?:https?:\/\/)?(?:www\.)?[-\w@:%.+~#=]{2,256}\.[a-z]{2,6}\b[-\w@:%+.~#?&\/=]*|)$/

Let me know the result

Thanks

Vikrant Yadav

Vikrant Yadav
Community Champion
March 30, 2022

For sharepoint site Regex would be something like this :- 

 

cfValues['URL Field Name'] ==~ /^https\:\/\/\w+(-my|-admin){0,1}\.sharepoint\.com((\/\w+[_\-\.']{0,}\w+){0,}[^\.](\w+[-_'\d]{0,})){0,}$/

Thanks

V.Y 

Like Madhu Reddy likes this
Madhu Reddy
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.
March 30, 2022

Thanks @Vikrant Yadav  This worked for me. 

Like Vikrant Yadav likes this

Suggest an answer

Log in or Sign up to answer