Agent Workspace - How to open a UI action in a sub tab instead of new window
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2021 01:23 AM
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.
- Labels:
-
Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2021 02:22 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2021 02:30 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2021 03:55 AM
Hi
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 09:13 PM
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
Request your expert inputs