- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 05:49 AM
For example if I have a URL that looks like below
From this url is it possible to get value of 'id' in catalog client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 06:43 AM
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);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 06:23 AM
Hi @Kalesh A1,
There may be multiple ways:
var url = document.URL.parseQuery();
if (url['id']){
var id = decodeURI(url['id']);
}
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var id = decodeURI(gUrl.getParam('id'));
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 08:22 PM - edited 09-21-2023 08:24 PM
1. For first code snippet it gave me a console error:
2. Second code snippet gave me a different JavaScript console error

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 12:00 AM
Hi @Kalesh A1,
Sorry, I was thinking backend 🙂
Try this:
function onLoad() {
alert(getParameterValue('id'))
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 06:26 AM
Hi @Kalesh A1
Please refer to below link for the code and explanation:
http://servicenowguru.com/scripting/client-scripts-scripting/parse-url-parameters-client-script/
Aman Kumar