Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

UI Action to Open URL

Ellis Richmond
Giga Contributor

I have a custom table that has a field that contains a URL to an external website. I would like a UI Action that opens that link in a new tab.

I have tried the following:

window.open(current.link, '_blank');

With no success. Is this actually possible?

 

Thanks,

Ellis

1 ACCEPTED SOLUTION

Hi Mate,

 

Sorry that was a server side call, I just wrote this and tested it. It works as you requested.

 

find_real_file.png

 

Script:

function onClick(){
	
var url = g_form.getValue('field_name');
	
g_navigation.openPopup(url);
}

 

Let me know how you go with this one.

 

If this answered your question please mark as correct.

 

Thanks

Mark

View solution in original post

6 REPLIES 6

Mark Skinner
Mega Guru

Hi 

 

If you would like to redirect to a URL on a UI Action you can try this:

 

var url = current.FIELD_NAME.toString();
gs.setRedirect(url);

 

 

find_real_file.png

Thanks

Mark

 

If this has been helpful please mark as so. If this answered your question please mark as correct

Hi Mark,

 

A couple of problems:

The link doesn't open in a new tab, it tries to open it in the current ServiceNow window and I get an error that the website refused to connect.

Also something I didn't mention in the question is I want this as a form link and your code only works with a form button.

 

Thanks,

 

Ellis

Hi Mate,

 

Sorry that was a server side call, I just wrote this and tested it. It works as you requested.

 

find_real_file.png

 

Script:

function onClick(){
	
var url = g_form.getValue('field_name');
	
g_navigation.openPopup(url);
}

 

Let me know how you go with this one.

 

If this answered your question please mark as correct.

 

Thanks

Mark

Great that's perfect. Thanks Mark