Shorten the url in URL type field in servicenow

Shubham Deep
Tera Contributor

Hi team,

 

I need your help in shortening the url mentioned under URL type field.

I have a URL type field and under calculated section with calculation type as script, I have given the script something as below:

  


return url; // return the calculated value

})(current);
 
 
The output is coming as long URL. Please guide me how to wrap the link in some customised form say "Link". so that in the form only link can be shown.
 
 
 
Thanks in advance,
Regards,
Shubham
 
3 REPLIES 3

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Shubham Deep You store a URL in a variable and can use it. Refer below script and modify accordingly

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0759336 

 

var url = 'www.google.com';
var linkName = 'Link Name';
task.work_notes = '[code]<a href="' + url + '">' + linkName + '</a>[/code]';

 

 

@Sid_Takali : Thanks for your suggestion. The above is not working for "URL" type field. I think it works in the task notes.

vishakhayadav24
Tera Guru

Hi @Shubham Deep 

var clickhere = '<a href="https://abc.service-now.com" target="_blank">ClickHere</a>';

        g_form.addInfoMessage(clickhere );
 
I have used this in client script and working find for me.
 
 
Thank you!
Vishakha Yadav