Client Script why can't use g_form.getQueryParameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
function onLoad() {
var myparam = g_form.getQueryParameter('myparam');
....
}
why ?
(g_env) [SCRIPT:EXEC] Error while running Client Script "Incident Demo01": TypeError: g_form.getQueryParameter is not a function
how to do ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
I think it is getParameter. Try this code
function onLoad() {
var myparam = g_form.getParameter('myparam');
....
}
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
The g_form.getQueryParameter() method is not a standard or documented method in ServiceNow's g_form API. The correct and widely used method for retrieving URL query parameters in client-side scripts is g_form.getParameter().
Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
Hello @KelvinY2025 ,
In ServiceNow, g_form =ONLY form fields control. It does not read URL parameters.
g_form.getQueryParameter() does not exist — that’s why you are getting:
Correct method to access parameters,
function onLoad() {
var myparam = g_url.getParameter('myparam');
console.log(myparam);
}
If this helps you then mark it as helpful and accept as solution for future queries.
Regards,
Aditya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14 hours ago
Hi @KelvinY2025 ,
User below code to retrieve query parameters from the URL
var myparam = g_form.getParameter("sysparm_myparam");
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
