Instance URL via JavaScript

kungfuu72
Giga Expert

I usually only use this code to create links within comments or e-mail notifications:

 

var html = '<a href="/nav_to.do?uri=' + current.getTableName() + '.do?sys_id=' + current.sys_id + '" target="blank">' + current.number + '</a>';

 

Are there any script include functions that I can call to get the instance URL to create the FQDN?

 

For example, clicking this link via an e-mail while a user is not logged on will give a 404 error.

If the comment resides in a dev instance I would want the URL to be: https://instancedev.servicenow.com/[URL HERE]

If the comment resides in a production instance I would want the URL to be: https://instance.servicenow.com[URL HERE]

 

Is there any way to call the DNS or FQDN via javascript? At least with the FQDN, I can parse it and trim it to what I need...

7 REPLIES 7

Welcome.



FYI: in our case the value is equivalent to the name/URL of our instance.


Wanted to let you know this code snippet solved a big problem for me today.   MANY THANKS!



-Paul Porter


kvhv0o7
Kilo Contributor

HI Daniel


how to use the logic in business rule to get link by clicking the incident number


now i am able to see the whole link but it looks complete link pasting here i need only incident number by clicking incident number i need to redirect to webpage this need to be done in business rule


can any one help on this??