Activity returning a page in exercise on Obj- methods
In the lesson "Interacting with an External Database", in the exercise, the OpenOffice activity has to return a page. In the solution there is an "Office" out parameter but I don't see it used in the steps. So how does it work?
When specifiying Office as an out parameter it means when calling that activity you can use any name to refer to the page being returned by the activity.
For example, if I call the OpenOffice activity with the following parameters:
ID = 1001
Office = OfficeDetails
When the activity runs the data associated with the office id of 1001, in this case the Cambridge office, the data will be on the clipboard in a page named OfficeDetails. Using a Page out parameter allows you the flexibility to name the page any thing you want.
You will not see the Param.Office reference in the activity. I have found that whatever Page Name parameter I have set up on the Parameters tab, when I use the same named page on the Step Page PRPC will swap the page names out. When referencing a page name you are not able to use the Param. prefix in the Step Page field. I have created a demo illustrating this.
On my Pages & Classes tab I have defined the following:
PageName = Office Class = SAE-HRServices-Data-Office
On my Parameters tab I have defined the following:
Name = ID Data Type = String Required = No In/Out = In
Name = Office Data Type = Page Name Required = Yes In/Out = In
Here is a screenshot of my activity:
When I test it these are the parameters I passed:
And this is the data returned to the OfficeDetails page on the Standard thread of the clipboard:
You can test this out again by typing in different values for the Office page parameter and you will notice the value you use for the Office page parameter will be displayed in the clipboard. That is if you do not use the Page-Remove method. Page-Remove will remove the page from the clipboard and you will not be able to see the page. In addition, it seems the Step Page does not allow the syntax of Param.Office when setting up the activity. I have found that whatever Page Name parameter I have set up on the Parameters tab, when I use the same named page on the Step Page PRPC will swap the page names out.
It appears to me that these [page] Params behave like passing by reference in PRPC (which is uncommon to Java - http://javadude.com/articles/passbyvalue.htm) since you pass in the Page Name or property and gets affected when returning. The Activity rules hides the fact that it somehow copies back the Step Page values to this Param In Page. Feels counter intuitive. When would we rather use an Param Out property?
The online help suggest that with Property-Set you could define a similar Open Office rule that only returns the OfficeName as output parameter String without (instead of) the whole Page property. But how can this output parameter be displayed on let's say the Test Page where I would expect it?
Would have been nice though if Pega actually explained the above is their courses for those who have a technical background. IMHO this topic is essential to any language or platform -- business-oriented or not.
PS. Why is there no "Add to favorites" for Activity rules in Pega 7.1.6?