Question
Capgemini
IN
Last activity: 10 Jan 2023 4:51 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.
-
Likes (4)
Vinay Kumar Miloslaw Frey Piotr Czubaszek Ashwani Mishra -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
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:
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()
Cognizant Technology Solutions
US
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.
Capgemini
IN
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?
-
Gaurav Londhe
Pegasystems Inc.
IN
Hi,
Can you try selecting "Dynamic Container" as the option and try?
Capgemini
IN
Dynamic container opens in same window.
Pegasystems Inc.
IN
You can try selecting Ajax and target as "Secondary"
Capgemini
IN
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:
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()
-
Ryouei Ding Prasoon Nalin Svetlana Chervinsky Praveena Devasenapathi Chunzhi Hong and 4 More
Pegasystems Inc.
JP
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.
Capgemini
IN
Thanks Richard.
Delta dental of california
US
@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.
Pegasystems Inc.
US
@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
-
sudhakar DEVARAKONDA Axel Stai
Delta dental of california
US
@RichardMarsot : Thank you, It worked.
Tech Mahindra
CA
@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
Infosys
US
@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.
Pegasystems Inc.
US
@Meghana Madala the preview button is only supported for link component that uses the openWorkItem or openWorkByHandle action
for reference - see the following articles
https://collaborate.pega.com/discussion/how-configure-preview-panel-theme-cosmos
https://collaborate.pega.com/discussion/theme-cosmos-open-work-object-full-portal-new-window
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.
CIBC
CA
@RichardMarsot we are able to open the case in the new tab using the script provided by you. but the Preview is not working as expected. when we click on the preview , it replacing the screen with the case instead of opening in the secondary ajax container as a side bar.we are on Theme-Cosmos:03-0.
Please advise.
CIBC
CA
@Venu gopala krishna @RichardMarsot could you look into my above issue. we moved Theme-Cosmos:04. but still having the issue.
Pegasystems Inc.
US
@Venu gopala krishna please open an SR - the collaboration center is not the place to troubleshoot issues - the code below just performs a window.open using the link generated - this is similar to doing a right click on a link where the preview button is shown and open in a new tab - if this is not working, likely the thread name is incorrect or some customization have been added that are breaking the functionality
try first with a clean Theme-cosmos app - using the myworklist and right click -> open in new tab on any case - it should open a case in a new new browser tab - preview or open assignment should be working - now replace the link by the action set provided above and it should do the same thing using a direct click.
Pegasystems Inc.
US
@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
-
Meghana Madala
Padmasri Dr.B.V.Raju Institute of Technology
IN
@RichardMarsot Run Script is not working for me
Pegasystems Inc.
US
@mudavathwithout 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
Updated: 5 Jul 2022 10:49 EDT
Padmasri Dr.B.V.Raju Institute of Technology
IN
sorry not to explain clearly @RichardMarsot please can you explain JS implementation clearly step by setp
Pegasystems Inc.
US
@mudavath if this code is not working - likely it is because the if condition is failing
the if condition checked that the link (A tag) has a valid href attribute - setting a breakpoint at the beginning of the function should help to debug the issue - the href should be set automatically when hovering on the link
Pegasystems Inc.
SG
@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.