Question
Last activity: 12 Jan 2021 10:37 EST
Open case in new browser tab
In Cosmos, the 'Open Work By Handle' action gives an option to open the case in new browser tab using right click. Is there a way to replicate this behavior by using a single click? I just want a link which opens the case in new browser tab.


Cognizant Technology Solutions
US
The event is 'click' and action is 'Open Work By Handle'. I can't find any options to open in a new window. The options that I see are 'default', 'ajax container' and 'dynamic container'. I opted for default and on single click, the case opens in current window but on the link when I do a right click and open in new tab, it opens the case correctly in new browser tab.
Could you please elaborate on what browser option you mentioned?


Pegasystems Inc.
IN
Hi,
Can you try selecting "Dynamic Container" as the option and try?
Dynamic container opens in same window.


Pegasystems Inc.
IN
You can try selecting Ajax and target as "Secondary"
Hi Mounika,
I tried the secondary AJAX container but nothing happened on click. Please correct me if I wrong, while using the secondary as target, don't I need to have a secondary embedded in my portal.
I just need to get the cases open in review mode in a different browser tab from the main case that the user is working on.
Accepted Solution
Updated: 12 Jan 2021 10:37 EST


Pegasystems Inc.
US
When you are using Theme-Cosmos, the href of a link will be automatically populated when you hover on the link - if you want to open the case in a new tab automatically on click (instead of using right click open in new tab), you can add a run script action that would do the window.open if the href is set.
Here is an example using Pega 8.5 and Cosmos 2.0 using the todo list on the home
the component is a link with the openWorkByHandle action on click -the preview panel will display when hovering over the button
add a new runscript action before the openWorkByHandle that will call the function openlinkinNewTab and pass the javascript event
Implement the JS function openlinkinNewTab - this function should be added into a JS rule-file-text and attached to the portal harness. For this post, I am just editing the UserWorkform fragment with the following code:
<script>
function openlinkinNewTab(event) {
var elem = event.target;
var hrefval = elem.getAttribute("href");
if( elem.tagName === "A" && typeof hrefval === 'string' && hrefval !== "#" && hrefval.length > 0) {
window.open(hrefval);
pega.control.actionSequencer.clearQueue();
event.preventDefault();
}
}
</script>
with this implementation, you will still have support for the preview panel but now the click with open the case in a new tab.
Note that the component must be link and the openworkbyhandle must be present as the 2nd action in the action set. The code above will look if the href is valid - if yes it will open the case using window.open and cancel the rest of the actions in the action set using clearQueue()
I tried the features around the right-click to open a case in a new browser. It works exactly as expected.
Here is the way to close a work case opened by right-click.
1. To Close by using browser's X button
The clipboard page of work case and the thread page "Thread: UserPortal_TabThread_nnnnnnnnnnnn" remain even after the case is closed.
2. To add a button whose click action is to close the work case
The work case clipboard page is closed but the thread page "Thread: UserPortal_TabThread_nnnnnnnnnnnn" remains there in the clipboard.
I wonder if it is recommend to add such a button and if there is any way to close the remaining thread page.
It should be the same link event with open in new window. The browser option to open new window as Tab should be set to true. This will open the new case or any other links to new tab on one click.