URL Variable Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 08:04 AM
What is the easiest way(if Possible) to make a URL field require the text entered to be "http://www.something.com". I have the variable setup to be a URL. I have example text in there, but it doesn't require you to type in the http://www before submitting the catalog item. You can type whatever you want in there and it will submit it. Once it's submitted you can't close the TASK that is setup because it gives this error "The following fields contain invalid text: Website URL.”

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 09:31 AM
Hi,
You could use the Validation Scripts mechanism. Navigate to System Definition > Validation Scripts.
Add a record:
Type = URL
UI Type = Desktop
Script =
function validate(value) {
var regEx = /(((ftp|http|https):\/\/)|(www\.))([-\w\.\/#$\?=+@&%_:;]+)/gi;
if(value == null || value == "") {
return true;
}
if(regEx.test(value)) {
return true;
}
return false;
}
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 11:28 AM
Mark - Thanks for the reply. I tried this and it doesn't work for me. I switched it from Desktop to Service Portal as that is where all of the requests are submitted. I was still able to submit by putting "ggg" into the variable URL field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 12:12 PM
Ah oke on the Service Portal.
I believe OOB there is a "sc_url" Validation Script. Could you test this one? Only default it is on UI Type "Desktop", so for testing purposes, you could change this to "Mobile / Service Portal" or just add another one.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 12:52 PM
Yeah it does nothing. I changed it to be "ALL" and I also changed it to Portal. Neither stopped me from submitting the Request with just "hi" and "hello" in the field. Very weird.