Catalog Client Script - ReferenceError: g_navigation is not defined

Oliver Anderson
Kilo Sage

I have a Catalog Item with one Select Box variable. Depending on the choice the user selects, I want the page to redirect to a different Catalog Item URL. I have created a Catalog Client Script on the Catalog Item called "Redirect URL." It has the following onChange script:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	//Type appropriate comment here, and begin script below
	var value = g_form.getValue('mt_issue_access');
	var accessUrl = 'sp?id=sc_cat_item&table=sc_cat_item&sys_id=42d84a101b1df5102d36751bdd4bcbe7';
	
	if (value == 'issue') {
		return;
	} else if (value == 'access') {
		g_navigation.open(accessUrl);
	}
}

The IF statement should open the URL specified when the "Request software access" choice is selected. However, when selecting that choice, I am getting the following Java exception: Error while running Client Script "Redirect URL": ReferenceError: g_navigation is not defined

javaexception.png

According to the documentation, it seems like g_navigation is a client-side class, so I'm not sure why it is showing as undefined. Here is the Catalog Client Script if needed:

clientscript.png

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

Hi @Oliver Anderson ,

try  top.window.location(accessUrl)

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

5 REPLIES 5

Trying to do same thing, g_navigation *should* have worked, but of course SN being SN, most things that should work don't.  Anyway, thank you for this correctly updated answer.