Open URL in new blank window

Virendra Dwived
Tera Expert

HI Everyone,

 

I have created one UI Action to launch one custom URL. I am using Client side and Server side both in one UI Action. So, to launch an URL I am using gs.setRedirect(URL) . But it opens that URL in same window rather than opening on new window.

 

Ex: I have this UI Action on incident form. Once this UI Action is clicked it open's the URL in same window. Whereas I want to open the URL in new window and keep the incident form as it is. 

 

Please help me in finding some solution. I have attached code of my UI Action below.

 

cc: @Ankur Bawiskar 

 

Thanks in advance

 

function Popup() {


        gsftSubmit( null, g_form.getFormElement(), 'popup_itsm');
   

}
if (typeof window == 'undefined')
    serverReopen();

function serverReopen() {

   var URL = "https://www.google.com"  // a custom URL will be used here, I have used it only as example
  gs.setRedirect(URL);

}

 

  

9 REPLIES 9

Anand Kumar P
Giga Patron

Hi @Virendra Dwived ,

function Popup() {
        gsftSubmit( null, g_form.getFormElement(), 'popup_itsm'); 
}
if (typeof window == 'undefined')
    serverReopen();
function serverReopen() {
   var URL = "https://www.google.com"  // a custom URL will be used here, I have used it only as example
   g_navigation.openPopup(URL);

}

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

 

Hi @Anand Kumar P 

 

I used your suggestion but now the button has stopped working. When I click on UI action it does not open URL. Rather it open's same UI Action's form.

 

Thanks 

Hi @Virendra Dwived ,

Mark sure client callable checked, Action name in ui action should be popup_itsm, Onclick funtion should be- Popup();
Try below one
top.window.location ="https://www.google.com";

var url = 'https://community.servicenow.com/';
window.open(url,'_blank');

 


If you want to get server side data and when click on that url navigate to data refrer below link
https://www.servicenow.com/community/developer-forum/ui-action-redirect-to-a-new-window-tab-using-se... 
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Saurabh Gupta
Kilo Patron

Hi,

 

function Popup() {
 g_navigation.open('https://www.google.com','_blank');
}


 

You can do it in client script as GlideNavigation is a client side API.

SaurabhGupta_0-1703154937915.png

 


GlideNavigation | ServiceNow Developers

 


Thanks and Regards,

Saurabh Gupta