How to Retrieve URL Parameters in a Catalog Client Script Without Using DOM in Employee Center Porta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 10:08 PM
Hello Community,
I am working with the Employee Center portal in ServiceNow and have opened a catalog form. I need to retrieve parameters from the URL of this catalog form using a Catalog Client Script, but I want to achieve this without relying on DOM manipulation.
For example, if the URL is:
https://<instance>.service-now.com/sp?id=sc_cat_item&sys_id=12345¶m1=value1
I want to extract the param1 value (in this case, value1) programmatically in a way that is robust and does not involve accessing the DOM directly.
Could someone guide me on the best approach to achieve this? Any code examples or best practices would be highly appreciated.
Thank you for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2025 11:12 PM
Hi @Mohan Mallapu ,
You can do something like below.
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var param1= gUrl.getParam("param1");
/// Or something like below.
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
if (!value) {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
value = gUrl.getParam("sysparm_id");
return value;
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 10:35 PM
Hi @Runjay Patel ,
GlideURL will not work on the employee center side and the second code using the DOM.