Unable to open multiple sub tabs with g_aw.openRecord in workspace client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 10:55 PM - edited 09-17-2023 11:18 PM
I want to open multiple sub tabs in workspace client script.
I have a UI action that has a code in workspace client script to get the list collector values from form. There is no issue in the param list. That part is verified.
If there are 3 selections in the list collector, it should open 3 sub tabs
Snippet
for (var i=0; i<users_list.length; i++) {
var user_query = '^first_name='+users_list[i];
g_aw.openRecord("sys_user", "-1", {"query": user_query });
}
Looping it in for loop but only opens 1 sub tab. If 3 users selected on form, open 3 sub tabs on sys_user table.
Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 11:56 PM - edited 09-17-2023 11:58 PM
Hi @Snehal13 ,
As per the documentation the second parameter should be sys_id, but you are passing "-1" and params accept readOnlyForm, defaultTab and hideDetails attributes.
https://developer.servicenow.com/dev.do#!/reference/api/tokyo/client/GlideAgentWorkspaceAPI
If your list collector is referring sys_user table you will have sys_id of users and you can pass them to the g_aw.openRecord method as second parameter to make it work.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 12:04 AM - edited 09-18-2023 12:04 AM
Sending -1 because I am opening a new record form. First param is table, second param is id of record / -1 if new record, 3rd param is list of params. I am sending correct. Tab is opening but only 1. I need to open multiple tabs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 12:18 AM
@Snehal13 got you!
I tried simulating this in my PDI and it worked perfectly, see the screenshot below. Please check the users_list variable contents and it's type. If possible please share your workspace client script code to check on this.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 12:20 AM - edited 09-18-2023 12:24 AM
var users_list= g_form.getValue('users_list').split(",");
for (var i=0; i<users_list.length; i++) {
var user_query = 'first_name='+users_list[i];
g_aw.openRecord("sys_user", "-1", {"query": user_query });
} // opens only 1 sub tab
Even if i do for loop for 3 times, 1 sub tab opens only. could you share the workspace client script that you simulated ?