Reducing the link size

vrushabh_m
Giga Contributor

I wanted to know about how to reduce the size of a link. I added a URL field to a form in ServiceNow and users can add any URL variable to it. But since URLs are lengthy, it occupies a larger chunk of the form. Is there any way where after user enters the URL and hits the lock button, the size of the URL gets reduced? 

4 REPLIES 4

Dr Atul - LNG
Tera Patron

Hi @vrushabh_m 

 

Request you please share some screenshot. 

I am not supposed to share the screenshot as per the policy of the organization I work for, but as you can see how a link is automatically truncated when you enter it in microsoft teams chat, similarly I was hoping if there is a way to truncate the link that is entered in the URL field.

 

Gangadhar Ravi
Giga Sage

you can try onLoad script like below. replace u_my_url_field_link with your field name.

function onLoad() {
  var url = g_form.getValue("u_my_url_field");
  if(url && url.length > 100) {
    var short_url = url.substring(0, 100) + "...";
    document.getElementById("change_request.u_my_url_field_link").innerHTML = short_url;
  }
}

Please mark my answer correct and helpful if this works for you.