The CreatorCon Call for Content is officially open! Get started here.

Unable to open multiple sub tabs with g_aw.openRecord in workspace client script

Snehal13
Kilo Sage

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

 
 
13 REPLIES 13

AnveshKumar M
Tera Sage
Tera Sage

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.

 

Thanks,
Anvesh

Snehal13
Kilo Sage

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

@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.

 

AnveshKumarM_0-1695021354423.png

 

Thanks,
Anvesh

 

 

 

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 ?