Agent Workspace - How to open a UI action in a sub tab instead of new window

Vaishnavi38
Tera Contributor

Hi,

I have an issue as when I click on a particular UI action in Agent workspace, its triggering to new window. 

My requirement is to when its clicked, it should open in new sub tab.

In UI Action, Under Workspace client Script, I tried the below code but didn't work.

 

function onClick(g_form)

{

var url= "incident_list.do?sysparm_query= " + g_form.getValue("called_id");

OpenUrl(url);

}

function OpenUrl(url){

this.open(url , '_blank');

}

Thanks in advance.

 

5 REPLIES 5

Sam Ogden
Tera Guru

Hi Vaishnavi,

You should be able to get it to open in a tab within the workspace without using the client side script.  If you look at the OOB Create Incident UI action on the interaction table, this opens a new incident within a new tab inside agent workspace.  

var canCreateIncident = false;
if ((current.isNewRecord() && current.canCreate()) || (!current.isNewRecord() && current.canWrite()))
	canCreateIncident = current.update();
else
	canCreateIncident = true;

if (canCreateIncident) {
	var inc = new GlideRecord("incident");
	inc.initialize();
	inc.caller_id = current.opened_for;
	inc.short_description = current.short_description;
	action.openGlideRecord(inc);
}

 

The last line seems to open the record

Hope this helps.

Ct111
Giga Sage

Hello,

Please use focus in the end like this

function openInNewTab(url) {
window.open(url, '_blank').focus();
}
//or
just

window.open(url, '_blank').focus();



There are more answer given here for this check that as well if the above one doesnt work.
https://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window/4907854

Mark my ANSWER as CORRECT and hELPFUL if it helps

Maik Skoddow
Tera Patron
Tera Patron

Hi @Vaishnavi 

you can use g_aw.openRecord() to perform that action.

See https://developer.servicenow.com/dev.do#!/reference/api/rome/client/GlideAgentWorkspaceAPI#gaw-openR... for more information.

Kind regards
Maik

Hello Maik,

 

g_aw.openrecord opens 1 tab at a time. I want to open multiple subtabs. Despite correct syntax and looping,  only one subtab opens. Property of tabs is set to 10.

 

My code is in workspace client script of ui action 

 

Please see https://www.servicenow.com/community/developer-forum/issue-with-opening-multiple-sub-tabs-in-workspa...

 

Request your expert inputs