URL field question

akillius
Kilo Expert

Hopefully this is an easy one for someone.   I added a URL field to my form for users to put specific web addresses (e.g, www.google.com).   When they click on the URL, it is appending our instance name before the address (e.g, https://instancename.service-now.com/google.com).   How do I prevent the instance name from appending?

 

Thanks,

Andy

1 ACCEPTED SOLUTION

tltoulson
Kilo Sage

Hi Andrew,



From a similar question I recently answered: URL Field Type



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"


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;


      }


})();


View solution in original post

8 REPLIES 8

harikrish_v
Mega Guru

Try giving the URL like this:-



https://www.google.co.in




Thanks & Regards,


Hari


Thanks for the reply.   Unfortunately, that will not work for what I am trying to accomplish.   There are hundreds of different urls in records and I attempted your suggestion and a it did not work.   Do you have an idea where this is set?


Not sure if this will work, but try setting this property to nil:-



glide.email.override.url




Thanks & Regards,


Hari


Hi Hari,



Just Fyi, Customers who want to display a custom base URL in email notifications can set the glide.email.override.url property.



Thanks,


Pradeep Sharma