UI Action setRedirect not working on external link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 01:26 PM
While trying to do a action.setRedirectURL to an external link, when I run the UI action, nothing happens. ServiceNow goes to a blank screen.
Code is as follows but I am at a loss as to understand why this is happening:
var url = 'http://www.yahoo.com';
action.setRedirectURL (url);
The Yahoo Link is just there for show and it won't go to the URL itself. This has been set up to be a non-client UI action so I'm not sure what I'm missing.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 05:29 PM
var url = 'http://www.yahoo.com';
action.setRedirectURL (url);
That's it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 05:11 PM
I don't think ServiceNow allows server-side redirects to external web pages (for security reasons). It must be client-side.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:01 PM
From what I can gather, for Security Reasons, ServiceNow will not do a Server side redirect to an external web page.
This makes sense when you think about it - you don't want the system redirecting to an external page that could run a phishing scam on your users.
You will need to use the code I provided to achieve your requirement.
Don't forget the HTTPS
function yourUIAction() {
var url = "https://www.yahoo.com";
g_navigation.open(url,"window");
//g_form.save();
}
if(typeof window == 'undefined')
yourServerCode();
function yourServerCode() {
//current.field = "xyz";
//etc
gs.addInfoMessage('Yahoo');
current.update();
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:08 PM
Wow Ugh. Is there any way to request access to an external link?
The only reason why is because I am trying to build a link to Google Maps with coordinates, based on info on the incident location.
Other than that, I did try the code you provided in a test environment while I wait for CAB to approve a change to UI.
What is the Window parameter in below?
g_navigation.open(url,window);
I am having loads of trouble trying to find info on g_navigation.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2018 06:33 PM
Oh? It's fully documented in the API.
https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=c_GlideNavigationV3API
Please note the correct syntax is below, i missed off the quotes.
g_navigation.open(url,"window");
PS
I am just assuming that the gs.setRedirectURL is a security thing.
It doesn't work for me either.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022