- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2021 03:32 AM
Hello All,
I am trying to get the URL parameters from the onLoad Client script when catalog item is loaded, here we are using an issue where in few scenarios the complete URL is getting loaded before the client scripts are running where in some scenarios the URL is loading after the client scripts ran, and resulting in null parameter values.
Example :
scenarios 1: URL is like (com.glideapp.servicecatalog_cat_item_view.do?v=1&&sysparm_id=SYS_ID&sysparm_myparm=SYS_ID)
Here parameter values are getting properly and URL is getting loaded at once.
scenarios 2: URL is like (nav_to.do?uri=%2Fcom.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26%26sysparm_id%3Da86e23491b64ac906417542d1e4bcbe0%26sysparm_myparm%3D70d0e7a2db3d381089ab6e9d13961914)
Here parameter values are getting as null because first a portion of URL is getting loaded(service-now.com/nav_to.do) and then the remaining url is getting appended.
Is there a way to hold the client script or any other way to achieve this?
Regards,
Prudhvi
Solved! Go to Solution.
- Labels:
-
Customer Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2021 04:16 AM
Hi,
Use this updated code for getParameterValue function. This will work for both the views as well as Service Portal
function getParameterValue(name) {
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;
}
}
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 02:57 AM
this is not working for me in scenario 2
Do you have any updated code, facing similar issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2021 03:53 AM
Hi,
did you alert the URL in client script?
does it show complete URL in both cases
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2021 04:05 AM
Hi Ankur,
Yes, I did in the 1st scenario it shows complete URL and in the second scenario it show only half portion of the URL.
Regards,
Prudhvi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2021 04:22 AM
if it is showing half then it won't give the values then by parsing the URL
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2022 03:09 AM
Hi Ankur,
I am facing similar issue, not getting proper URL in scenario2, but in scenario1 getting correct URL.
Can you please tell how to get correct URL in scenario2 also?