Posting to External URL via UI Action

brandon_chamber
Kilo Contributor

Does anyone know if either of the following two are possible:

1. Redirect to an external URL for a UI Action (using a form button and the action.setRedirectURL() function). I can get it to link to an external URL, but the URL shows within the ServiceNow Iframe. I'd like to open a new tab/window to display the external URL.

2. Is it possible to execute a POST rather than a GET when redirecting to the external URL from #1?

Thanks for any input.

Brandon

5 REPLIES 5

justin_drysdale
Mega Guru

1:



var url = 'google.com';
//open in new window:
var win = window.open(url);
win.focus();


2:
See the following:
http://stackoverflow.com/questions/8389646/send-post-data-on-redirect-with-javascript-jquery

It looks like jQuery is the way to go here.


1: This should do it.



if (window.location != window.parent.location) {
window.parent.location = "http://google.com";
}


brandon_chamber
Kilo Contributor

Thanks all for the input.


howardelton_ave
Kilo Explorer

Was this ever resolved?   The responses so far are assuming client side scripting however the question was about creating a new tab via server side code. action.setRedirectURL() is typically used at the end of a UI action, but I cannot find any information on the "action" object to see if there are other methods that might help. We basically want to run server side code in a UI action (that generates the URL string) then spawn a new page instead of redirecting. While it is possible to have client side code in a UI action, it typically runs before the server side code, not after. It would be easier if the action object had a method other than setRedirectURL() that could be used.



Does anyone have any info on this object?