UI Builder - Close tab and redirect back to list tab

Jonas VK
Tera Guru

Hi all, 
I am wondering if it is possible to close a tab that has been opened from a list that is shown from the list menu. and after clicking a button to go back to the list tab. (see images) 

find_real_file.png

From this screen i want to close this tab and show the List again to the user. 

find_real_file.png

the list view in question

 

if anybody knows a way on how to do this and could help me out

Regards,
Jonas 

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I'm not sure we have a way to programmatically close a tab, and you can generally use the link to destination event handler to send the user back to another tab, but I don't know that you can do it with the list tab there.

A workaround might be just displaying a message that tells the user they can close the tab.

View solution in original post

11 REPLIES 11

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I'm not sure we have a way to programmatically close a tab, and you can generally use the link to destination event handler to send the user back to another tab, but I don't know that you can do it with the list tab there.

A workaround might be just displaying a message that tells the user they can close the tab.

we came to the same conclusion in our team. 
thanks for helping to look 

Hey Brad, we should be able to do it using dispatched events. Have a look at my answer below.

Stephanie35
Tera Contributor

We created a UI Action:

  • Table: Main table for your application
  • Active, Show Insert, Show update, and Client all checked
  • Onclick is onClick(g_form)
  • Condition is true
  • Script: 
    • function onClick(g_form) {
      g_aw.closeRecord();
      }

Stephanie35_0-1681406993300.png

 

Then you add to your Event within your Application: "Execute UI Action (Glide Form)"

Find the Sys ID for your UI action (listed in the bottom black line) and fill it in.

OR

Write a Client script: 

api.data.gform.executeUiAction({actionSysId: <sysid>}); // Close the tab 

 

Fair warning is that we do sometimes have issues where it doesn't actually close and redirect. Most of the time it works, sometimes it doesn't. I have a feeling it has to do with async issues when called in the Event.