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.
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.
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?
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.
- 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.
- 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.
Thanks Richard.
@RichardMarsot Our Use case is to have link in a preview panel which opens assignment in a new browser tab, the solution suggested here doesn’t seem to open the assignment in new tab when I configure it on the preview panel.
@RichardMarsot Run Script is not working for me
@RichardMarsot Hi Richard,
Is there any way we can limit the opening of cases using right click of case from My work/Dashboard. User are opening multiple cases at a time and it’s leading to memory saturation issue.
Thanks,
Mahesh M
Hi,
Can you try selecting “Dynamic Container” as the option and try?
You can try selecting Ajax and target as “Secondary”
@RichardMarsot: We have requirement to disable preview option on link component and at same time we want the list of options that facilitate the user to open the case in new browser tab and browser window.
We were able to disable preview using no-peek-preview helper class but this in turn disables the open the case new browser tab and browser window options for right click event. In our case we just want to disable preview but not the right click options. Could you please provide any inputs on the same.
@Meghana Madala the preview button is only supported for link component that uses the openWorkItem or openWorkByHandle action
for reference - see the following articles
We decided to not support the openAssignment action for the preview button since after opening the case in a new tab, the user can see the task list and open the assignments that is assigned to him.
@Meghana Madala FYI - I wrote a new article that explains how to open an assignment in a new browser tab using a regular button with theme-cosmos - see https://collaborate.pega.com/discussion/how-open-assignment-new-browser-tab-using-theme-cosmos
@mudavath without more details - hard to know what is the issue - make sure that the function is loading - try to call it directly from the console of your browser dev tools - add a debugger statement in the function to figure out where it is failing
@RichardMarsot : I have a strange issue here using the script above, it works perfectly when using it as an administrator but when my non-admin users click on the link, the case does not appear. I thought it might have to do with permission but some cases will appear for them but not all of the cases. No errors or exceptions in tracer or browser developer tool. Any idea how to troubleshoot? Thanks.
Dynamic container opens in same window.
@SUDHAKARD0386 no-peek-preview is used to disable the preview button and will not set the href on the link.
If you want to hide the preview button but still set the href, you can create this helper class in the CSS file attached to your skin rule and use this helper class on the link control
@RichardMarsot : Thank you, It worked.
@venugopalakrishna @RichardMarsot could you look into my above issue. we moved Theme-Cosmos:04. but still having the issue.



