Open a URL in UI Builder

Steve Stivers1
Tera Contributor

I am working in Utah UI Builder and I need to open a new browser tab with a link to an attachment on a record. I can build the URL and it works in the Text Link component but the user has to click the link to open the new tab.

 

I need to open it without the user clicking the link. In my page script I have tried:

top.window.open('https://www.google.com','_blank') ;
g_navigation.openPopup(URL);
 
All of these fail. How can this be done?
1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You can use the link to destination event handler on the page ready event like this:

  1. Click the Body component on your UIB page in the left hand content tree.
  2. Click the Events tab in the configuration panel on the right.
  3. Click Add event mapping and choose Page ready
    BradTilton_0-1692219049290.png
  4. Choose Link to destination and Select destination
    BradTilton_1-1692219133036.png
  5. From here you can link to a workspace page in a new workspace tab or select external to open a page outside of workspace (like google)
    BradTilton_3-1692219222541.png
  6. Click OK and Add.

This would cause a new browser tab with google.com loaded on page load.

View solution in original post

9 REPLIES 9

Hi Brad,

 

Not working, attached evidence with Page Ready:

 

Screenshot 2024-09-18 113856.png

 

On the other hand, if I associate the event to a button, it works.

 

Screenshot 2024-09-18 114322.png

 

Why doesn't it work when loading the page?

 

Thanks in advance.

 

Regards.

 

You might have to add a timeout. My guess would be race conditions.

Hi Brad and thanks for you reply, how do we add timeOut?

 

Regards.

Hi Brad,

 

I have tried with the “Text Link” component and it only works if the “Open new window” tab is activated.

 

Is it possible that there is a bug in the ui builder and for that reason it does not work with Add event mapping and choose Page ready?

 

We need to be redirected to a URL when loading the page.

 

Thanks in advance.

You'd do it in a script with a setTimeout function I'd think.