UI Action setRedirect not working on external link

tahnalos
Kilo Sage

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.

21 REPLIES 21

var url = 'http://www.yahoo.com';
action.setRedirectURL (url);

 

That's it

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

The SN Nerd
Giga Sage
Giga Sage

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

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

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