Service Portal - Is there an easy way to pass a parameter into the URL?

davilu
Mega Sage

I know to use $sp.getParameter('sys_id') to grab the sys_id from the URL, but is there an easy way to do the opposite - pass a parameter into a URL?  For instance, our page url is /portal?id=sample_page, if we wanted to pass the sys_id of the clicked item into the url, how would we do that?  (e.g. /portal?id=sample_page&sys_id=1234567890)

1 REPLY 1

Michael Jones -
Giga Sage

I don't believe there is an easy way to what you are asking exactly - the url parameters are a read-only collection. The only way to add a parameter would be to reload the page, passing in a new url with your parameter added to it. 

In a widget, for example, as part of an onclick() you would have to call something like: 

var url = $window.location.href;
var params = '&sys_id=xxxxxxxx'
$window.location = url + params;

That would reload the page with the existing URL + the added parameters. 

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!