Theme-Cosmos: Open work object in Full portal on Copy sharable Link

Opening the work object in theme cosmos full portal on Copy sharable link (simple URL) is available from the Pega 8.5.1 release. This document explains the necessary steps to make the copy sharable link in full portal.

  1. Configuring the simple URL.
  2. Configuring the supportive activity.
  3. Overriding the pyIsAutoGenThread when rule.
  4. Configuring the Copy sharable link action.

1.Configuring the Simple URL :

  • It is mandatory to configure the simple URL so that the URL looks like simple path.
  • Configure URL Mappings
    • Save as the pyDefault in application ruleset if needed.
    • URL Mappings will be available in Dev Studio - > Records → Technical → URL Mappings
    • Add the URL alias

  • Click Next

2.Configuring the supportive activity:

  • Create the new activity OpenItem(Can be any name, make sure the same is reflected in the URL Mapping) in an application ruleset and Work- class

Parameters :



Name



Data type



Required



WorkID



String



No



WorkPool



String



No

Pages and Classes :



Page Name



Class



pxThread



Code-Pega-Thread



newTabTempPage



Work-

Steps :

  1. Property set :
  2. Property set :
  3. Call pxOpenWorkItemNewTab
  4. Security Configurations

Provide the correct Privilege name

3.Overriding the pyIsAutoGenThread

  • This is an important step to make the copy sharable link to open in portal and works correctly. Override the pyIsAutoGenThread in an application ruleset and class should be @baseclass always.

Condition :

pxThread.pxThreadName contains (ignore case) "autothread"

4.Configuring Copy sharable link :

  • Copy sharable link is an action configurable on any work object. Create an action in the respective navigation pyWorkCommonActions

Configure the actions for the copy sharable link :

  1. Run Script
  • This run script will copy the simple url to the clipboard
  • Function Name :
    • CopyContentToClipboard
  • Parameters :
    • SimpleURLValue : D_pzSimpleURL.pyURL

Add this code snippet if the function is not available in the build on app

/* 
The below function is for copying parameter value to systems clipboard 
*/
function CopyContentToClipboard(SimpleURLValue) {
  
   /*Replacing spaces in url to avoid breaking of URL links*/
  if(SimpleURLValue.indexOf(" ")!=-1){    
    SimpleURLValue=SimpleURLValue.replace(/ /g,"%20");    
  }
  
  var textArea = document.createElement("textarea");
  textArea.style.background = 'transparent';
  textArea.value = SimpleURLValue;
  textArea.textContent = SimpleURLValue;
  document.body.appendChild(textArea);
  textArea.select();
  try {
    document.execCommand('copy');
  } 
  catch (err) {
  }
  document.body.removeChild(textArea);
}
  1. Local action
  • This is used to show the overlay that the url is copied to clipboard

  • Refer the pySharableLinkCopied from Pega-Social ruleset and make the same changes in the respective ruleset.

Once the URL is copied to clipboard open the new browser tab and paste the copied link to open the work object in full portal.

@krism2 I faced an issue when I followed the implementation guide especially for the when rule @baseclass.pyIsAutoGenThread (step 3). The defined condition didn’t work well. If condition

  • @String.contains(@toUpperCase(pxThread.pxThreadName),@toUpperCase(“autothread”))

is used instead, it work as expected:

  • user is logged in and has permissions - the system opens an independent new tab with the instance behind the link
  • user is not logged in and has permissions - the system opens an independent new tab with the login screen, after login the instance behind the link opens in this tab
  • user doesn’t have permissions - (after login) the system presents an appropriate message that access is denied

Apart from this, just as an information, the URLMapping rule has some limitations when it comes to the usage of this configuration in an implementation layer.

  • 1st configuration dialog - Because of the auto-completes, they don’t accept DCR (e.g. =D_crmAppExtPage.WorkClass_), (leaf) classes where the mapping will be enabled need to be selected manually (Though the auto-completes show only those classes)
  • 2nd configuration dialog - the same for the WorkPool definition - any value will be recognized as a class name, not as a property reference

To have this more flexible and inherit into the implementation layer without additional modifications (which require dev access), the URLMapping rule should support DCR/Global Resource Naming (GRN).

@krism2 Thank you for publishing this. First three steps verified to work on 8.7 ! (We didn’t need the copy shareable link part)

Can you please elaborate on the significance of the pyIsAutoGenThread WHEN rule, and what other use cases may be impacted by altering its implementation?

If you want to create a new case type instead of opening a case, you can follow the same process

1/ Create a new URL Mapping rule for create - call a new activity createNewWork

2/ Create a new activity CreateNewWork that takes className as parameter

3/ set the when rule pyIsAutoGenThread as indicated in the main doc

4/ Override UserHeader in your layer and add a new section UserHeaderOverride

4/ Implement UserHeaderOverride as a non auto Section with the following content

this section will override the OOB function loadNewTabWO and add support for the new action name called createnewWork


```
<script>
  pega.desktop.infinity.loadNewTabWO = function() {
    if (typeof newTabactionName != "undefined" ) {
      if(newTabactionName === ""){
        return;
      }
        newTabIsReloaded = "true";
        if (newTabactionName === "createNewWork") {
           pega.desktop.createNewWork(newTabClassName,"", "pyStartCase","", "", "", false);
        }
        if (newTabInsHandle !== "") {
            if (newTabactionName === "openWorkByHandle") {
                openWorkByHandle(newTabInsHandle, '', '', '', 'false', 'false', {
                    target: "dynamicContainer"
                });
            } else if (newTabactionName === "openWorkItem") {
                openWorkItem(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>
```

@krism2

Thanks for the explanation but I am bit confused about If I can (somehow) use URL mappings for my business case or not.. or even necessary to use..

We are providing a service which is supposed to return direct access case links to the requestor in our response payload.
We have the pyIds or pzInskKeys in hand..

What I am wondering is that If there is a way call this URL mapping rule and give me back a link that I can use … Or any other way to build up a direct access link of the case ?

@krism2

(Env: Pega Platform 8.7.3)

I faced an issue that if the user has not logged in the pega platform yet, when click the url , Pega log in page will be show up, and enter operator id / pwd to login, but after login , instead of case review page only shows user portal page. If the user already logged in the platform, then this issue does not happen, it shows case review page correctly after click the url.

To resolve this issue, it seems like we need to add a parameter to above activity step.2 , set Param.pxUseDXapi to true. Or, we need to ensure in the application setting, Advanced>> UI Runtime >> React-Based UI is selected. or (server-rendred UI >> enable reacted-based landing page )

@krism2 : Please can you advise how to embed this in an email so i can generate the link ?

@RichardMarsot can you help tell the steps to open an assignment and harness with full portal i tried by changing the action name to openAssignment but still i was unable to see the case details opened

Note:

We have seen scenarios, where users uses URL Mapping to open/create workobject by directly activities New/Open Workobject. This is incorrect, as it does not load/paint the UserPortal.
So, please note that while doing URL Mapping, it is important that we paint the UserPortal and then perform any operation.
It will make sure that all the required resources(such as Harness, CSS, styles etc.) get loaded properly.

Regards,
Rachit

@topra actually yes, we can and it works:) It even supports cases from different applications / workpools.. and even one of them is enough ..

basically, whatever you configure at URL mapping comes after the host name of the machine (which ideally can be retrieved from application settings) and the activity you put does the job.

So the link can be used something like

https://YourHostAddress/prweb*/Cases/{param1}/{param2}*

It is all crystal clear now :slight_smile:

@liang Modern enterprise applications using Pega would use Single Sign On (SSO) for authentication which - if not already authenticated - triggers the required authentication flow.

Once SSO authentication is complete, the original request (to the shareable link) would typically be replayed back to the Pega application, and newly authenticated users will get the same result as users who were already signed in.

@PriyankaS16772776

The URL copied to the clipboard in the Javascript code at the end is the value of D_pzSimpleURL.pyURL with spaces substituted with a %20 sequence.

You could implement a calculated case property or a Data Page that does something similar so that it becomes simple to reference in a Correspondence rule.

Also, The URL formed should be formed using the URL from Application URL alias under Application definition, which would consist of the Appname,

Calling the URL directly without the app-name would produce incorrect results.

Eg:

https://URL:8443/prweb/URLMappingIdentifier - > This is incorrect.

https://URL:8443/prweb/app/app-name/URLMappingIdentifier - > This is correct.

Hope this helps.

@AVIKCEMK

Do you find that the clipboard page AccessGroup.pyPortal consistently resolves to the default portal of the access group that is engaged by the application alias?

If so, then you could try using that in place of the hardcoded “UserPortal” value set to param.PortalName in the earlier screenshot that showed the configuration of the activity run by the URL Mapping.

@AydınToprak : I tried this but it does not open the item from different application. If you are in application a and tring to access appplication b, it opens it but not in a correct portal. The portal is getting distorted

Hi @RichardMarsot
We followed the steps mentioned by you to create new case in new tab. It is working fine from dev/app studio log in → launch user portal- > than open the URL in new browser tab but not loading from access group with default portal as UserPortal. It is giving SECU0019.

Unauthorized request detected : Unregistered request encountered with params pyActivity:@baseclass.doUIAction action:createNewWork eventSrcSection:
We tried many ways to register this activity with help of few support article but no luck. can you please help what is the best way to register this to avoid this security block?

We are on

Pega Platform 8.8.5

@JagannathP17215284 to fix this issue you need to register the activity - see https://support.pega.com/question/pegadesktopcreatenewwork-403-forbidden-error

You will see this error in the ALERTSECURITY log file (not pegaRULES.log)

Circum: 00falseNA**NANANANANANANANAUnauthorized request detected : Unregistered request encountered with params pyActivity:@baseclass.doUIAction action:createNewWork eventSrcSection:

To fix it you need to register the activity

1/ create a new section UserHeaderInc2 before the UserHeaderOverride and use the content from the section called “UserHeaderInc”. You need to save with a new name because UserHeaderInc is final

2/ Use the code below in your new UserHeaderInc2 section on line 36 – className should be coming from your createWork activity used in the semantic URL and is defined on line 29

ClipboardPage actionPage = pega.getUIEngine().getUIActionPage(“createWork”);

actionPage.getPage(“pyActionAPI”).putString(“pyClassName”, className);

actionPage.getPage(“pyActionAPI”).putString(“pyFlowName”,“pyStartCase”);

pega.getUIEngine().getUIAction(actionPage).register();

Properties on pxThread and pxRequestor are available that make the application alias of the requestor who is constructing the URL available. This is so that - where appropriate - this part of the URL can be dynamically built instead of hard-coded.

@BraamSmithCLSA/ Team

We have to give a worklink in a correspondence through , which user will be able to open the work object(with full portal access) and access the assignment in it .To access PEGA application , currently , user , uses a SSO link which has one custom auth service and application alias in it like https://host.pegacloud.net/prweb/PRAuth/AuthService/applicationalias.

While, user click on the work link -->expectation is user will go via the same SSO link like above and they need to have one application specific access group -->and then only the work object should open .

Using URL mapping ->how can we address this ?

@AVIKCEMK has you viewed this article yet? I found combining the current post and the below worked fine in getting to the case

https://collaborate.pega.com/question/application-alias-urls-open-id-sso

If you want to open the assignment too, i’m afraid I’m not aware, we only ever landed directly on a case and let the user open the assignment. If you go to the Assignment level, then you have to worry about multiple assignments or even if that assignment doesn’t exist anymore. If you talk to the business, landing on the case is usually happy medium and more applicable for any scenario (vs. building specific logic for each assignment and scenario)