Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Issue with opening multiple sub tabs in workspace client script using g_aw.openRecord

Snehal13
Kilo Sage

This code is written in workspace client script section of a UI action. This work fine but opens only 1 tab. I want to open 3 tabs.

 

for (var i=0; i<3; i++) {
          var user_query = '^first_name=Anthony';
          g_aw.openRecord("sys_user", "-1", {"query": user_query }); // -1 because it is a new record and no sys id
}

 

1 ACCEPTED SOLUTION

sarahakers
Tera Guru

I was finally able to get this to work and open mulitple tabs. Prior to doing so it would open the last tab.  

I had to implement the timeout and call it from the loop instead of nesting it in the loop. It should have worked just fine the way @Ratnakar7 has it outlined but it didnt. 

 

I had to adjust to

 

for (var i =0; i<answer.length; i++){

timeMe(answer[i].table, answer[i].sys_id)

}

function timeMe(table,sysid){

setTimeout(function(){

g_aw.openRecord(table,sysid);

},1000);

}

View solution in original post

5 REPLIES 5

sarahakers
Tera Guru

I was finally able to get this to work and open mulitple tabs. Prior to doing so it would open the last tab.  

I had to implement the timeout and call it from the loop instead of nesting it in the loop. It should have worked just fine the way @Ratnakar7 has it outlined but it didnt. 

 

I had to adjust to

 

for (var i =0; i<answer.length; i++){

timeMe(answer[i].table, answer[i].sys_id)

}

function timeMe(table,sysid){

setTimeout(function(){

g_aw.openRecord(table,sysid);

},1000);

}