Client Script why can't use g_form.getQueryParameter

KelvinY2025
Tera Contributor

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 ?

10 REPLIES 10

palanikumar
Giga Sage
Giga Sage

I think it is getParameter. Try this code

function onLoad() {
var myparam = g_form.getParameter('myparam');

....
}

Thank you,
Palani

(g_env) [SCRIPT:EXEC] Error while running Client Script "Incident Demo01": TypeError: g_form.getParameter is not a function

SumanthDosapati
Mega Sage
Mega Sage

@KelvinY2025 

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

KelvinY2025_0-1764205471641.png

KelvinY2025_1-1764205490232.pngUsed under sow, it doesn't work