- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2012 03:36 AM
Can we redirect to any other page or homepage using client script.
I need that if the IF condition true then redirect to homepage.Please help me out
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2019 12:44 PM
I know this post is old and Harsh might have got his answer but just in case someone stumbles upon this post and looking for a way to redirect using client script then below code snippet might help:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'expense_freight_realestate'){
var redirectURL = 'https://www.google.com/'; //url to redirect; this approach works in platform and Service Portal view
top.window.location = redirectURL ;
}
}
Please note that in case you want to open up external link within the main ServiceNow Frame then you may use g_navigation.open() but this approach doesnt work when the Service Catalog/form will be used in Service Portal.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2012 05:37 AM
Just set window.location to redirect from client-side script.
https://developer.mozilla.org/en-US/docs/DOM/window.location

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2015 06:52 AM
The ServiceNow way to do it would be:
getTopWindow().NavPageManager.get().getPane('gsft_main').loadLinkFromUrl( <url> );
This makes it look seemless to the user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2015 10:31 AM
Hi Fogg,
This is not working for me, the client side code is triggered but it does not takes me to the url.
getTopWindow().NavPageManager.get().getPane('gsft_main').loadLinkFromUrl("http://www.google.com");
This is the code I am using.
Regards
Pratul Agarwal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2015 11:03 AM
I believe this only works for internal URLs to the ServiceNow instance.
For external ones you will need to do something like window.location = "http://www.google.com";