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
2 weeks ago
Hi @Diogo Ramos,
if you want to create loop with "safeguard" create data resource that just intake 1 parameter as integer which will be your dynamic count of pages and it will be stored in state. Data resources are "self-re-triggering" every time state will change if that state is "binded" into DR. This Data Resource will be returning either true if count is more than 0 or false if 0 and on success event in your client script you will first decide whether output of DR returned true or false. If true, you will decrement the count in state (causing the DR to retrigger) until the count is 0, that's where you return false from Data Resource and your client script will "RETURN".
This is how I would try it.
- 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
