Using document.URL within a Business Rule

josephtucker
Giga Contributor

I'm fairly new to servicenow scripts, however I'm looking into extracting the current URL via a business rule.

I've noticed var instanceURL = gs.getProperty("glide.servlet.uri") will return the instance URL, however it does not return the current URL that I'm seeing.

I've tried utilizing document.URL; but noticed that does not work (returns with an error).

Would there be another method for extracting the current URL within a Business Rule script?

Thanks in advanced.

6 REPLIES 6

Anurag Tripathi
Mega Patron
Mega Patron

Hi Joseph,



This will give you the instance URL -> gs.getProperty("glide.servlet.uri")


And this will give you the rest -> gs.action.getGlideURI()


-Anurag

Hi Anurag,



Thanks for the help.



Looking farther into this, it appears the URL that I'm attempting to grab is a reverse URL (reverse proxy).


So for example instead of seeing :


http://foo.service-now.com for the URL


I'm seeing


http://foo.bar.com for the URL



it seems that gs.getProperty("glide.servlet.uri") returns the first URL rather than the latter.


Yes Joseph,



gs.getProperty("glide.servlet.uri") returns the first URL and gs.action.getGlideURI() will return the latter.


-Anurag

It seems that the return of gs.action.getGlideURI() returns something along the lines of:



view_content.do?sysparm_stack ... etc



rather than:



http://foo.bar.com



perhaps this could be different from system to system?