Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

getParameter not working onLoad

Vinya Jakkula
Tera Contributor
Hi Team please help!!!
getting error as g_form.getParameter is not a function in portal.
function onLoad() {
    // Check if the user is not an admin
    if (!g_user.hasRole('admin')) {
    // Get the current sys_id from the URL parameter
    var itemSysId = g_form.getParameter('sysparm_id');
    alert(itemSysId);

 

            if (url) {
                top.window.location = "/help?id=sc_cat_item&sys_id=" + itemSysId;
            }
                }
    }

 

3 REPLIES 3

CezaryBasta
Tera Guru

I don't think there is a getParameter function available in the GlideForm class. I see you are already using the top.window.location object to set the URL, have you tried retrieving it with it?

--
See more of my content here.

Iam getting the sysid but JavaScript error getting in browser console.

johnfeist
Mega Sage

Hi VInya Jakkula,

 

getParameter() is a server side function that is normally used as part of an AJAX call.  Since you are in a load situation, your best bet is probably creating a display business rule that will put the sys_id of the item in question onto g_scratchpad which you can then access in your On Load client script.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster