Client Script why can't use g_form.getQueryParameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2025 08:58 PM
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
11-26-2025 08:54 AM
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
11-26-2025 04:58 PM
js_includes_clientSc…0-11-2025_0527:5568 (g_env) [SCRIPT:EXEC] Error while running Client Script "Incident Demo01": ReferenceError: g_url is not defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2025 05:58 PM
Used under sow, it doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2025 08:55 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2025 06:01 PM
Used under sow, it doesn't work
