Discussion
Pegasystems Inc.
US
Last activity: 3 Apr 2023 8:28 EDT
How to open an assignment in a new browser tab using Theme-Cosmos
Currently it is possible to configure a link component to open a case in a new browser window using the openWorkItem or openWorkByHandle action - the preview button is displayed on this link and generate an href that can be used to open the case using the right click mouse action
Unfortunately, this functionality is not available for open assignment and this requires the user to open the case in review mode first and then open the assignment.
You can find more details on this functionality in the articles:
- https://collaborate.pega.com/question/open-case-new-browser-tab
- https://collaborate.pega.com/discussion/theme-cosmos-open-work-object-full-portal-new-window
The goal of this document is to offer the ability to show an 'open in new tab' button in the worklist that will open directly the assignment in a new browser tab - the component would be a regular button that would use a customized JS api to open the assignment
Note: this demo was done on 8.7 with Theme-Cosmos 4.0 - this functionality might not be possible with older versions of Theme-Cosmos.
To achieve this functionality, we will need to replace a function called loadNewTabWO already shipped as part of the Theme-Cosmos ruleset and extend it to support the openAssignment functionality - this function is defined in pz-cosmos-ui-utils.js
1/ Extend the loadNewTabWO functionality
Create a custom non-auto section in your application with the name UserHeaderOverrideInc and add the following code to the non-auto section
<script>
function openAssignmentInNewTab(insKey) {
window.open(pega.desktop.infinity.generateNewTabURL() + "&actionName=openAssignment&insHandle=" + insKey);
}
pega.desktop.infinity.loadNewTabWO = function() {
if (typeof newTabactionName != "undefined" ) {
if(newTabactionName === ""){
return;
}
newTabIsReloaded = "true";
if (newTabInsHandle !== "") {
if (newTabactionName === "openWorkByHandle") {
openWorkByHandle(newTabInsHandle, '', '', '', 'false', 'false', {
target: "dynamicContainer"
});
} else if (newTabactionName === "openWorkItem") {
openWorkItem(newTabInsHandle, '', '', '', 'false', 'false', {
target: "dynamicContainer"
});
} else if (newTabactionName === "openAssignment") {
openAssignment(newTabInsHandle, '', '', '', 'false', 'false', {
target: "dynamicContainer"
});
}
}
if (newTabactionName === "showHarness" && typeof newTabClassName != "undefined" && typeof newTabRuleName != "undefined") {
let replaceCurrent = false;
tabName = typeof tabName != "undefined" ? tabName : "";
preActivityName = typeof preActivityName != "undefined" ? preActivityName : "";
preActivityParams = typeof preActivityParams != "undefined" ? preActivityParams : "";
preDataTransform = typeof preDataTransform != "undefined" ? preDataTransform : "";
if (newTabRuleName === "SearchResultsPage") {
tabName = "searchResults";
replaceCurrent = true;
}
pega.d.showHarness(tabName, newTabClassName, newTabRuleName,
preActivityName, preActivityParams, "", false, preDataTransform, replaceCurrent, true, "");
}
newTabactionName = "";
newTabInsHandle = "";
newTabClassName = "";
newTabRuleName = "";
preActivityName = "";
preActivityParams = "";
tabName = "";
preDataTransform = "";
var url = new SafeURL("pzPagesToRemove");
url.put("PagesToRemove", "newTabTempPage");
pega.u.d.convertToRunActivityAction(url);
pega.u.d.asyncRequest('POST', url);
}
pega.desktop.infinity.hideBusyIndicator();
};
</script>
this code defines a new function called openAssignmentInNewTab and redefines the function loadNewTabWO by adding a new if condition for newTabactionName = 'openAssignment'
Note: upgrading to a new version of Theme-Cosmos will require to up merge the changes / fixes done in the OOB back into this function.
2/ Add this section to the UserHeader section
Resave the UserHeader to your app ruleset and add this custom section to the region - Because it is added to the UserHeader, the override function loadNewTabWO will take precedence with the one shipped OOB in Theme-Cosmos
3/ Configure the button to call the function openAssignmentInNewTab
for this example, we will add it to the section HomeWorklistorQueueItem
you can find a RAP of the 3 rules below.