Need to include instance url in HTML of widget

pandeyved
Tera Contributor

Hi all I have configured a widget, where I need to use relative URL means instance name should come dynamically.

pandeyved_0-1700813516818.png

If you can see Get in touch with your local UHD is the hyperlink, but in backend I have given hardcoded url but I want to give it dynamically
<a href="https://servicenow-dev.i.instance.com/esc?id=services" style="margin: 10px 0;white-space: pre;">Get in touch with your local UHD</a>
Please guide How I can use it for dynamic use.

Thanks

2 REPLIES 2

AnveshKumar M
Tera Sage
Tera Sage

HI @pandeyved 

 

You can use gs.getProperty("glide.servlet.uri") to get the URL of instance, like https://serv-dev.service-now.com/ in your server side script and store it in the data variable like,

 

 data.inst_url = gs.getProperty("glide.servlet.uri") + "esc?id=services";

 

 

Then in your HTML you can use this like,

 

<a href="{{c.data.inst_url}}" style="margin: 10px 0;white-space: pre;">Get in touch with your local UHD</a>

 

 

This will take care of instance name dynamically.

 

You can also use other sys_property called instance_name to get just the name of the instance.  

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

Thanks,
Anvesh

Musab Rasheed
Tera Sage
Tera Sage

Hello,

No need to define any property, you can directly give link like below

<a href="/esc?id=services" style="margin: 10px 0;white-space: pre;">Get in touch with your local UHD</a>

or you can use ng-href as well

<a ng-href="?id=services">${Home}</a>

Try both, I think it should work.

Please hit like and mark my response as correct if that helps
Regards,
Musab