URL Field Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 02:21 PM
I have a url field type on a form, a users enters a website into that field, however, if you click the website, it adds the website after the instances URL? Any idea how to move the instance url all together?
when users clicks URL in the field --> ex. https://TestInstance.service-now.com/www.google.com
what should happen when a user clicks URL in the field --> ex. www.google.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 06:29 PM
When typing the URL into the field, "http://" or "https://" should be included before the URL. If you leave off the protocol, the url is treated as relative to the instance url. If you include the protocol, the url is treated as an absolute URL. So the url entered should read "http://www.google.com"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 06:32 PM
Ah!! Thanks!
Is there any way around that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2014 06:43 PM
The requirement for the protocol prepended to the url is a HTML specification implemented by browsers themselves, so there is no way around that.
Within ServiceNow you could add a client script and/or business rule to check the url field for http:// and add it if it is not present. This would remove the requirement for users to include it themselves. For example:
Client Script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if ((newValue + '').indexOf('http://') == -1) {
g_form.setValue('url', 'http://' + newValue);
}
}
Business Rule (before)
(function() {
if ((current.url + '').indexOf('http://') == -1) {
current.url = 'http://' + current.url;
}
})();