Question
Pegasystems Inc.
US
Last activity: 22 Jun 2016 20:25 EDT
How do you construct a page with JS upon login to PRPC
In Pega Academy we have the ability to share a link to a course such as this one:
https://pdn.pega.com/pega-academy/my-self-study?CourseID=C-119
Clicking on this link will take you (after authentication) directly to the course. This is straightforward because a course is a physical entity in PA.
We now have a requirement to show a portion of the course library (such as what is shown below) after clicking on a URL. The issue is that this is not a destination - it is constructed using JS and data pages/transforms/etc when a person clicks the following sequence: Course Library > By Product > Marketing. My question is, does PRPC 7.1.9 have a way to use parameters from a URL to build this upon log in? If not, is there another way to do this? Is this possible in 7.2.x?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
IN
Hello Sean,
Not sure, whether I understood your requirement clearly, however if you want to parameterize the URL, you may follow the below code snippet.
Example code snippet:-
<a href="javascript:window.location=createDynamicURL();" > employee info </a>
or
<a href="#" onclick="RedirectURL();return false;" > employee info </a>
In JS file, add the below function:-
Hello Sean,
Not sure, whether I understood your requirement clearly, however if you want to parameterize the URL, you may follow the below code snippet.
Example code snippet:-
<a href="javascript:window.location=createDynamicURL();" > employee info </a>
or
<a href="#" onclick="RedirectURL();return false;" > employee info </a>
In JS file, add the below function:-
function createDynamicURL()
{
//The variable to be returned
var URL;
//The variables containing the respective IDs
var companyID=...
var branchID=...
var employeeID=...
//Forming the variable to return
URL+="company=";
URL+=companyID;
URL+="/branch=";
URL+=branchID;
URL+="/employee=";
URL+=employeeID;
URL+="/info";
return URL;
}
Alternatively, you may use the below function:
// Usage:
// var data = { 'first name': 'George', 'last name': 'Jetson', 'age': 110 };
// var querystring = EncodeQueryData(data);
//
function EncodeQueryData(data)
{
var ret = [];
for (var d in data)
ret.push(encodeURIComponent(d) + "=" + encodeURIComponent(data[d]));
return ret.join("&");
}
Note:- In your use-case, you may replace the variables mentioned above with property values present on clipboard.
Please check the applicability of above suggestion for your use-case.
Regards,
Ajit
Pegasystems Inc.
US
Thanks for your response Ajit.
However it appears that you are providing code to construct a URL from JS. What I actually want to do is construct something with JS that is passed in via a URL. This is a hypothetical series of events:
1) User clicks on a URL such as: https://pdn.pega.com/pega-academy/my-self-study?CourseID=C-119 however, the URL contains parameters that execute JS upon login instead of opening a course
2) Once the user is authenticated, the params in the URL are passed to the showHarness function which looks like this:
pega.desktop.showHarness = function(tabName,className,harnessName,preActivityName,preActivityParams,keyValue,readOnly,preDataTransformName,replaceCurrent,skipConflictCheck,contentID,dynamicContainerID,skipReload) {
var oSafeURL = new SafeURL();
oSafeURL.put("name",tabName);
oSafeURL.put("ClassName",className);
oSafeURL.put("HarnessName",harnessName);
oSafeURL.put("preActivityName",preActivityName);
oSafeURL.put("preActivityParams",preActivityParams);
// remaining code in function follows..
The tabName, className, etc have to be passed in as params so that the JS can take the first steps to build the desired screen.
3) The course category screen is built and the user can click on the desired course.
Thanks for your response Ajit.
However it appears that you are providing code to construct a URL from JS. What I actually want to do is construct something with JS that is passed in via a URL. This is a hypothetical series of events:
1) User clicks on a URL such as: https://pdn.pega.com/pega-academy/my-self-study?CourseID=C-119 however, the URL contains parameters that execute JS upon login instead of opening a course
2) Once the user is authenticated, the params in the URL are passed to the showHarness function which looks like this:
pega.desktop.showHarness = function(tabName,className,harnessName,preActivityName,preActivityParams,keyValue,readOnly,preDataTransformName,replaceCurrent,skipConflictCheck,contentID,dynamicContainerID,skipReload) {
var oSafeURL = new SafeURL();
oSafeURL.put("name",tabName);
oSafeURL.put("ClassName",className);
oSafeURL.put("HarnessName",harnessName);
oSafeURL.put("preActivityName",preActivityName);
oSafeURL.put("preActivityParams",preActivityParams);
// remaining code in function follows..
The tabName, className, etc have to be passed in as params so that the JS can take the first steps to build the desired screen.
3) The course category screen is built and the user can click on the desired course.
So I want to create a URL (via an activity) that has these params and can be read from a JS function upon login, not build a URL from JS. Can this be done in 7.1.9? Do I need 7.2?
Pegasystems Inc.
IN
Hello Sean,
So if we simplify the requirement, the series of events be like below(correct me if its wrong)
1. User clicks on a link/icon/button.
2. A new window opens up/existing window gets replaced.
3. User gets authenticated.
4. User could see a list of courses available.
If this is the case, then you may follow the below steps.
1. Configure the button/icon with 2 action sets.
a. Run activity - which will create a page containing the all the required parameters
b. open URL in window/ launch harness(whatever is applicable for you) and use the page created above to pass the parameters in this action set.
Please let me know if the above suggestion helped for your use-case.
Regards,
Ajit
Pegasystems Inc.
US
You understand the requirement, and I agree that clicking a button/link or whatever will call an activity which will generate the URL, but my question essentially remains - how do I populate the URL so that PRPC 7.1.9 can use the params to call the required objects upon logging in? Does 7.1.9 do this? Do I need 7.2?
Pegasystems Inc.
US
Does anyone have any input on this? Even a link to something similar would be welcome.
Pegasystems Inc.
US
Sean,
If you can call an activity, you can pass it parameters. You can map those values to the clipboard and from there feed the JavaScript in whatever harness you display, so the short answer is yes, Pega 7.1.9 can support this. I don't know of any out of the box tools to make it easy. I think you're going to have to have to write custom code to make it work. I'd break it down into pieces. Can you create the call to the activity with values for the required parameters X, Y, and Z? Can you create a portal/harness/section that takes clipboard values A, B, and C and displays the courses you want? Then you just need a property-set to map your parameter values to the properties. Honestly, the custom JS is probably the trickiest part, but if you've already got the code to make the above screen shot work, hopefully you can leverage that for much of the heavy lifting. Good luck!
Thanks,
Mike
Pegasystems Inc.
US
I appreciate the difficulty of both what I am requesting and what needs to be done here. To be absolutely clear, lets say I want to create a URL right now, on the mesh with no activity. In the URL I will reference the destination server which is: https://pdn.pega.com/pega-academy/my-self-study
Next, I will need to pass PRPC parameters in the URL that will allow it to invoke JS to dynamically build the proper response:
https://pdn.pega.com/pega-academy/my-self-study?js=showHarness?param1?param2...
The JS looks something like this:
pega.desktop.showHarness = function(tabName,className,harnessName,preActivityName,preActivityParams,keyValue,readOnly,preDataTransformName,replaceCurrent,skipConflictCheck,contentID,dynamicContainerID,skipReload) {
var oSafeURL = new SafeURL();
oSafeURL.put("name",tabName);
oSafeURL.put("ClassName",className);
oSafeURL.put("HarnessName",harnessName);
oSafeURL.put("preActivityName",preActivityName);
oSafeURL.put("preActivityParams",preActivityParams);
// BUG-96226 03/06/2013 GUJAS1 Added null check for ContentID & DCID.
I appreciate the difficulty of both what I am requesting and what needs to be done here. To be absolutely clear, lets say I want to create a URL right now, on the mesh with no activity. In the URL I will reference the destination server which is: https://pdn.pega.com/pega-academy/my-self-study
Next, I will need to pass PRPC parameters in the URL that will allow it to invoke JS to dynamically build the proper response:
https://pdn.pega.com/pega-academy/my-self-study?js=showHarness?param1?param2...
The JS looks something like this:
pega.desktop.showHarness = function(tabName,className,harnessName,preActivityName,preActivityParams,keyValue,readOnly,preDataTransformName,replaceCurrent,skipConflictCheck,contentID,dynamicContainerID,skipReload) {
var oSafeURL = new SafeURL();
oSafeURL.put("name",tabName);
oSafeURL.put("ClassName",className);
oSafeURL.put("HarnessName",harnessName);
oSafeURL.put("preActivityName",preActivityName);
oSafeURL.put("preActivityParams",preActivityParams);
// BUG-96226 03/06/2013 GUJAS1 Added null check for ContentID & DCID.
if (contentID != null){
oSafeURL.put("contentID",contentID);
}
if (dynamicContainerID != null){
oSafeURL.put("dynamicContainerID",dynamicContainerID);
}
If I can figure out how to build a URL manually that will allow me to build my response dynamically then the activity portion is straightforward. Any input building a URL manually?