Getting the Current URL

Recently ran into this wall which stumped me for a few.  Had to get the full URL including the path from a UI Page on the server.  Using my book as a reference (shameless plug) I found RP.getReferringURL(), but this only returns the page name I found out and RP is not a usable object everywhere.

The solution was to find the actual Request object through the Transaction.

//
var tr = new GlideTransaction.get();
gs.print(tr.getRequest().getRequestURL());
//

So what is happening here? GlideTransaction.get() returns the current transaction. It has a scriptable method ‘getRequest()’ which returns the underlying request for this transaction which an HTTPServletRequest. Not every method is going to be available since SN has whitelisted/blacklisted many but getRequestURL().

There you have it the full URL with the path! What other methods have you found to get the URL?

Leave a Reply

Your email address will not be published. Required fields are marked *