- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 10:51 AM
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
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:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 11:13 AM
Hi @Oliver Anderson ,
try top.window.location(accessUrl)
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 11:13 AM
Hi @Oliver Anderson ,
try top.window.location(accessUrl)
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 11:20 AM
Tried this and got an error stating top.window.location() is not a function
So I did top.window.location = accessUrl and that did work, thank you!
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') {
top.window.location = accessUrl;
}
}
However, now I'm realizing that the browser is going to warn that work may be lost, since they have technically filled out the request. Any ideas on how to bypass this warning and immediately redirect to the URL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 11:25 AM
@Hemanth M1 I used Google and found this lol:
top.window.onbeforeunload = null;
Inserting this code before the top.window.location line prevented the popup from appearing. Everything is working perfectly now, thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 08:45 AM
and thank you for this too 🙂