Question

3
Replies
210
Views
sony reddy pasunoori (sonyreddyp)
Charles Schwab & Company Inc

Charles Schwab & Company Inc
US
sonyreddyp Member since 2020 1 post
Charles Schwab & Company Inc
Posted: December 15, 2020
Last activity: December 29, 2020
Posted: 15 Dec 2020 16:33 EST
Last activity: 29 Dec 2020 11:47 EST

Use javascript api functions(runActivity or openURLInWindow) instead of safeURL

In the below code Iam using safeurl to run activity and return the url 

Code 1:

  function onClick(url,typeOfAttachment){ 
    var eventObject = {}; 
    var workURL = new SafeURL('ActivitClass.ActivityName');
    workURL.put('url',url);
    workURL.put('typeOfAttachment',typeOfAttachment);
    
    var options = {
                url: workURL.toURL(),
                event: eventObject
            }; 
    pega.api.ui.actions.openURLInWindow(options);
       
  }  
  

  Replaced the above code to use openURLInWindow JavaScript api 

Code 2:

function openURLInWindowOnClick(url,typeOfAttachment){
var eventObject = {};

var options = {
                activity: {
                  name: 'ActivityClass.ActivityName',
                  parameters: [
                    {name: "url", value:url, isProperty: true},
                    {name: "typeOfAttachment", value: typeOfAttachment, isProperty: true}
                  ]
                },
                event: eventObject
            };

   pega.api.ui.actions.openURLInWindow(options);
            
}

  Expected : Functionality of Code 2 should replicate Code 1

***Edited by Moderator: Pooja Gadige to add platform capability tag***
Pega Platform 8.2.2 User Experience