Open multiple tabs at the same time in Configurable Workspace via UI action

Jasmine Haywood
Kilo Expert

Hello. Is there a way to open multiple tabs at once in the configurable workspace/workspace experience via a UI action? I was able to use action.openGlideRecord() to open one record successfully, but all of the records created before the final record created  that I wanted to open are skipped.  Only the final record created is opened in a new tab in the workspace. I have also tried using g_aw.openRecord() as well, however I get an error stating that 'org.mozilla.javascript.ECMAError: "g_aw"' is not defined.' So it appears the the glide agent workspace api does not work in the now experience Configurable workspace. I am in a scoped app and on an instance updated to San Diego.

 

The use case is an agent will be creating multiple 'cases' in our custom app, via a UI action on the parent record. In order for them to see all of their newly created cases at once, the request to have all of those cases open in a separate tab on our workspace so that the agent could navigate and work through all of the cases at once and not have to navigate back to the parent record. 

1 ACCEPTED SOLUTION

Jasmine Haywood
Kilo Expert

One of my teammembers was able to provide me with a solution.

 I was concerned that this method created for agent workspace wouldn't work for configurable workspace, but it looks like it does. For the method g_aw.openRecord(), you need to use this in conjunction with GlideAjax if you're going to use it in a UI action. For the UI Action I created, I had the method called in the wrong place. Instead of the top script section, I needed to use the WS client script section. I also needed to set the UI action 'client' toggle to true. In the WS client script section, I toggled the 'format for configurable workspace' option. From there, I used glide ajax to get the information I needed sent to a script include that was creating the records I wanted. Once I created the records, I sent them back as a list along with the tables they were created on and from there I was able to use g_aw.OpenRecord method in a for loop. 

 

In my script include

var recordList = [];//create a record array to store list of objects
var obj = {};//create an object to stire the values needed for g_aw.openRecord()

if (meets criteria for new record 1) {
var newRecord = new GlideRecord ('table name");
newRecord.initialize();
newRecord.short_descripton = table_name.getValue("short_description");
newRecord.description = table_name.getValue("descripton");
newRecord.insert():
obj = {
"table" : "table name",
"sys_id": newRecord.sys_id + "" //Made into string
}
recordList.push(obj);//push object to array
}
if (meets criteria for new record 2) {
var newRecord2 = new GlideRecord ('table name 2");
newRecord2.initialize();
newRecord2.short_descripton = table_name.getValue("short_description");
newRecord2.description = table_name.getValue("descripton");
newRecord2.insert():
obj = {
"table" : "table name 2",
"sys_id": newRecord2.sys_id + "" //Made into string
}
recordList.push(obj);
}

return JSON.stringify(recordList);

 

In the workspace client script

var sys = g_form.getUniqueValue();
var glideCall = new GlideAjax("name of script include for glide ajax");
glideCall.addParam("sysparm_name", "name of function inside script include");
glideCall.addParam("sysparm_record","sys");
glideCall.getXMLAnswer(openRecord);

function openRecord (answer){
if (answer) {
answer = JSON.parse(answer);
for (var step = 0; step < answer.length; step++){
g_aw.openRecord(answer[step}.table, answer[step].sys_id);
}
}
}

View solution in original post

4 REPLIES 4

Jasmine Haywood
Kilo Expert

One of my teammembers was able to provide me with a solution.

 I was concerned that this method created for agent workspace wouldn't work for configurable workspace, but it looks like it does. For the method g_aw.openRecord(), you need to use this in conjunction with GlideAjax if you're going to use it in a UI action. For the UI Action I created, I had the method called in the wrong place. Instead of the top script section, I needed to use the WS client script section. I also needed to set the UI action 'client' toggle to true. In the WS client script section, I toggled the 'format for configurable workspace' option. From there, I used glide ajax to get the information I needed sent to a script include that was creating the records I wanted. Once I created the records, I sent them back as a list along with the tables they were created on and from there I was able to use g_aw.OpenRecord method in a for loop. 

 

In my script include

var recordList = [];//create a record array to store list of objects
var obj = {};//create an object to stire the values needed for g_aw.openRecord()

if (meets criteria for new record 1) {
var newRecord = new GlideRecord ('table name");
newRecord.initialize();
newRecord.short_descripton = table_name.getValue("short_description");
newRecord.description = table_name.getValue("descripton");
newRecord.insert():
obj = {
"table" : "table name",
"sys_id": newRecord.sys_id + "" //Made into string
}
recordList.push(obj);//push object to array
}
if (meets criteria for new record 2) {
var newRecord2 = new GlideRecord ('table name 2");
newRecord2.initialize();
newRecord2.short_descripton = table_name.getValue("short_description");
newRecord2.description = table_name.getValue("descripton");
newRecord2.insert():
obj = {
"table" : "table name 2",
"sys_id": newRecord2.sys_id + "" //Made into string
}
recordList.push(obj);
}

return JSON.stringify(recordList);

 

In the workspace client script

var sys = g_form.getUniqueValue();
var glideCall = new GlideAjax("name of script include for glide ajax");
glideCall.addParam("sysparm_name", "name of function inside script include");
glideCall.addParam("sysparm_record","sys");
glideCall.getXMLAnswer(openRecord);

function openRecord (answer){
if (answer) {
answer = JSON.parse(answer);
for (var step = 0; step < answer.length; step++){
g_aw.openRecord(answer[step}.table, answer[step].sys_id);
}
}
}

Does this still work for you? I'm trying to do the same thing on Utah but it will only open one tab

Did this work for you ? It only opens 1 tab for me in csm workspace. Ui action is client callable.

 

Below sample workspace client script code opens just 1 subtab and not 3 

 

for (var i=0; i<3; i++) {
var user_query = '^first_name='+users_list[i];
g_aw.openRecord("sys_user", "-1");
}

 

Did this work for you ? It only opens 1 tab for me in csm workspace. Ui action is client callable.

 

Below sample workspace client script code opens just 1 subtab

 

Why this code opens only one tab and not 3 times

 

for (var i=0; i<3; i++) {
var user_query = '^first_name='+users_list[i];
g_aw.openRecord("sys_user", "-1");
}