Getting URL Parameters in Scoped Application

harshvardhan_11
Giga Expert

I am trying to get URL parameter through catalog client script in Scoped Application. But since Scoped application don't have access to the window object, I am not able to autofill the variables

 

I found an article

https://community.servicenow.com/community?id=community_article&sys_id=df735b72db21d7444fc2f4621f961...

which suggest to use GlideURL class, but I am recieving an error in console 

ReferenceError: GlideURL is not defined

 

Can anyone please help me with how to get URL parameters in Scoped Application.

 

Thanks in Advance

5 REPLIES 5

Jace Benson
Mega Sage

You should be able to use this in the client side;

GlideURI.get('param');

https://docs.servicenow.com/bundle/madrid-application-development/page/app-store/dev_portal/API_refe...

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Harshavardhan,

Try GlideURI in scoped app. If that doesn't work have your catalog client script in global scope and it should work.

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Syvo
Mega Guru

In NY release, in a scoped app, I ended up using "top.location".

 function onLoad() {
	var url = top.location.href;
	var param = new URLSearchParams(url).get("my_param");
        console.log(param);
}

I'm definitely not happy with this because the use of "top" is a hack and could stop working anytime. GlideURI or GlideURL would be the way to go if only we could use them in a scoped catalg client script on Portal.

Hi,

Does this work in Service Portal onLoad as well?

Did you try that?

Regards

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader