Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get 'id' value of service portal URL in catalog client script

Kalesh A1
Tera Contributor

For example if I have a URL that looks like below

https://xxx.service-now.com/sp?id=I_NEED_THIS_VALUE&sys_id=XXXXXXXXXXXXXXXXX&sysparm_category=XXXXXX...

 

From this url is it possible to get value of 'id' in catalog client script

1 ACCEPTED SOLUTION

Vishal Birajdar
Giga Sage

Hi @Kalesh A1 

 

Yes you can get it.

onLoad clinet script 

     //get URL
    var gUrl = top.location.href;
alert(gUrl);
var getId = gUrl.split('?')[1].split('&')[0].split('=')[1];
alert(getId);

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

7 REPLIES 7

I tried this one, this solution works for other URL parameters, but not for 'id'.

Vishal Birajdar
Giga Sage

Hi @Kalesh A1 

 

Yes you can get it.

onLoad clinet script 

     //get URL
    var gUrl = top.location.href;
alert(gUrl);
var getId = gUrl.split('?')[1].split('&')[0].split('=')[1];
alert(getId);

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Thanks, this worked