Discussion
Pegasystems Inc.
US
Last activity: 11 Feb 2022 13:35 EST
How to change the browser tab name with Theme-Cosmos
One of the important feature in Theme Cosmos is the ability to open cases in different browser tabs - this functionality allows to leverage the browser tab functionality (move tabs, extract tab as a separate window...) and makes it easier to work on multiple cases at the same time.
To differentiate which case is loaded, Theme-Cosmos will set the title of the tab as <Case type name> - <Case ID>
If the page is landing page, the harness description will be displayed.
Using the browser favicon + the title makes it easy to work on multiple cases concurrently
If you want to change the favicon, you can update the fragment pyPortalIcon and provide a .ico file and 2 png files
to update the title of the tab to include other pieces of information (for example the pyLabel of the case), you can resave the fragment the pyMetaTags into your application ruleset. The fragment is inserted before the title attribute and setting the value of the title in the fragment will take precedence over the one generated automatically by the harness generation
Here is a screenshot of the pyMetaTags rule that would provide the same functionality as the OOB implementation. We can see from the code that the title is obtained differently if this is a case vs a page
Let's assume that we want to use the OOB functionality for all the pages except for a case page - and in this case, we want to show the case ID followed by the case label. This is how the fragment would be updated
<%
if (!tools.getPrimaryPage().getString("pyID").isEmpty()) {
String windowTitle = StringUtils.crossScriptingFilter(tools.getPrimaryPage().getString("pyLabel"));
String workID = StringUtils.crossScriptingFilter(tools.getPrimaryPage().getString("pyID"));
windowTitle = workID + " "+ windowTitle;
%><title><%= windowTitle %></title><% } %>
If we repeat the same exercise, this is how the browser tabs will render
Note: this was tested on Pega 8.6 but should work for older Pega Infinity 8.x releases
This will not work if you open the end user portal as a secondary portal - secondary portal is a developer feature to help see your end user portal - Make sure to test with your user logged in to the end user portal as the default portal in your access group.