gaidem
ServiceNow Employee
Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
12-07-2011
06:48 PM
I've been needing to evaluate URI paramaters in areas of the application where the RP object hasn't been available. With a pointer from Tyler Jones I found a great script on stackoverflow.
Here is what you want to do:
Create a new script include named gup:
Script:
function gup( name, url_pass ){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( url_pass );
if( results == null ) return "";
else return results[1];}
Now you can access this doing something like this in a client script:
var x = GUP('parm name' window.location.href);
Or this in a server script:
var x = GUP('parm name', gs.getSession().getStack().top());
You will be returned with the value for that paramater.
1 Comment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.