- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2025 02:29 AM
Is there any way to get the ServiceNow URL in a client script? I tried: sysparmQuery = g_form.getParameter('sysparm_query'); But it didn’t work as expected. Is there another way to get the value of `classification` from the URL? For example, the URL:
1.
2. https://dev123408.service-now.com/_to_do_comment.do?sysparm_query=_computer_information%3D__ENC__ZjZ...
I need to get the value of `classification`.
please help me,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2025 03:36 AM
did you print what came in alert using this?
alert(top.location.href);
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-06-2025 02:52 AM
Hi @Nguyen Van Au
Try the below cript..
function onLoad() {
var url = new GlideURL(window.location.href);
var urlParam = url.getParam('classification');
g_form.addInfoMessage('Value of classification: ' + urlParam);
}
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2025 03:29 AM
I have used window.location.href and top.location.href but still haven’t been successful.
My situation is that the client script is written and runs on a new form.
For example, from List A, I click a button that sets the URL, then go to Form B, which is the form I am working on.
I need to get the URL value that is returned.
However, it seems that using window.location.href and top.location.href does not work.
Is there any other way to get my current URL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2025 03:03 AM
you are writing client script on which table?
are you redirecting user from somewhere to this URL and then want to write onLoad to get that value?
try this to grab the value in client script
function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var classification = gUrl.getParam("classification");
alert(classification);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-06-2025 03:32 AM
Yes, this is a client script that will run on that exact URL.
By setting the URL beforehand and then clicking a UI Action, I navigate to the form I am working on.
I need to get the classification value in order to show or hide the “Buy” button.
Unfortunately, I have tried and it did not work.