Opening multiple records/tabs from a button in ui builder / workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2024 12:37 AM
Hello everyone I'm investigating 2 possibilities:
- Have a button upon multiple selection of related list records, that opens those same records in different tabs in the workspace. (When users click on a related list, it opens the record right away and redirects to the record tab, users might want the same behavior as when you click CTRL + Record in a list, which just adds a tab on top and the user is not redirected right away to that tab), this is what I want to accomplish.
- Have a custom button on a custom page in ui builder that opens X records, but emitting X number of events. WIthin UI builder I can emit events that create a tab for a given record without redirecting, but I'm not able to emit multiple events for some reason, see below.
For 1, I created a related list action (Now Experience Framework -> Declarative Actions -> Related List actions :
Here I tried the supposed to be most simple solution by creating a FOR loop and using
g_aw.openRecord
This works, but only for 1 record, it never works within a for loop and I tried in multiple SN versions.
On top of this I've tried other different ways, using open(), top.window.open, this.open, all of these open the url but on new browser tabs, not within the workspace.
So , does anyone have idea how to get this one working ? Is it even possible as a client / server script? I'm thinking on going the UXF Client Action way, but for that my option 2 must work.
For 2, I just created a simple button for testing purposes :
Then on that client script I have something like:
api.emit("NAV_ITEM_SELECTED", {
route: 'record',
fields: {
table: "incident",
sysId: "7a8e5f1493b10210f62d77f08bba1044"
},
params: null,
redirect: null,
passiveNavigation: true,
title: "An Incident",
multiInstField: "sysId",
targetRoute: "current",
external: null
});
api.emit("NAV_ITEM_SELECTED", {
route: 'record',
fields: {
table: "incident",
sysId: "17db1f5093b10210f62d77f08bba100f"
},
params: null,
redirect: null,
passiveNavigation: true,
title: "An Incident",
multiInstField: "sysId",
targetRoute: "current",
external: null
});
This also only works on the first record. So even if I go the UXF Client Action way, at the moment I cannot trigger multiple tabs at the same time, even using passiveNavigation: true.
So if anyone has an idea how to get it to work let me know 😄

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 10:42 AM
instead of having one event handler that makes 2 api calls, have you tried having 2 event handler that make only one call each?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 11:05 PM
That could work most likely, the problem is that the amount of records I want to open is dynamic, so I would need some kind of dynamic event handler to trigger X amount of times depending on how many selections I had. At the moment I have not found a way to build something like that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 10:37 PM
There is a way to do this but I'd advice against it. This may impact your workspace performance.
So, the thing with using OOTB navigation event is that as soon as you trigger it, it would take you to the next page.
Now, for your use case, you need a custom solution. Here is how it can work.
1. Create a custom page in UIB. Create a required parameter with sysids.
2. Use "tabs" component and use a repeater inside the tabs component to render multiple tabs dynamically.
3. Now, setup your record page inside the repeater. This may need some work as you have to build the record page yourself, but it should be doable using controllers.
4. Now, from your button you can navigate to your custom page by passing all the sysids.
5. On your custom page, you must write the logic to read those sysids and build the payload for your repeater component.
ServiceNow Community Rising Star 2022/2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 11:03 PM
Interesting way to think about it, but indeed a bit extreme for what I need. My question is also how does the list component do it? Because when you are on the list component and you do ctrl + click on a record, it opens 1 or multiple tabs for the record (if you do it multiple times),which are basically sleeping until you click on them, so any idea of what type of event is triggered there?