Can you please show with screen shots how to iterate over the PAGE Group pyQuestionGroup. I was able to find the length of Question Group as @Utilities.SizeOfPropertyList(.pyQuestionGroup).
Also please show with screen shots how to PAGE COPY a PAGE Group in an activity.
I have found iterating through Page Groups is syntactically the same as iterating through Page Lists.
If it is a full copy of one Page Group to the other, you may find that a single Set statement in a Data Transform does the job:
Set .TargetPageGroup equal to .SourcePageGroup
If you are looking to append(/merge) the contents of the source page group into an existing target that already has other items in it, iterate over source page group and use each element’s .pxSubscript property to determine the ‘key’ you need to set in the target.
Again look to use the Data Transform rule for copying properties or pages, and you might be surprised how few steps are needed.
@BraamCLSA thanks for pointing to the .pxSubscript property while iterating. That did the trick. I was really hoping some one as knowledgeable as you would also be posting screen shots.
I calculate EACH subscript of the Page Group in step 5.0 and do Page-Copy in step 5.1 as
OLDSurvey.pyQuestionGroup(param.ss) into NEWSurvey.pyQuestionGroup(param.ss) within my activity as shown below
One line of code to copy an entire Page Group - very clean, neat and simple - but to understand/debug and get this one line of code to work took so much effort and a serious tip from a PEGA CLSA.
I learned the pxSubscript technique through inspecting the Clipboard Viewer of each entry in a Page Group to see if there was a way I could identify each of the elements. I encourage you to explore the Clipboard Viewer and Tracer as the key tools to help you learn the next level of detail about what is available at runtime to influence your design approach.
Also, challenge yourself on whether this needs to be an Activity.
Steps 2 and 3 can be fulfilled with Data Pages that use Lookup as their Data Source;
Steps 4, 5.0 and 5.1 are property assignments using the Data Page loaded from Step 2, which can be implemented using a Data Transform.
If after Step 5 you are doing something to copy the old survey to the new, and then even to persist the new survey to its data store, these too can be accomplished with Data Transforms and Savable Data Pages respectively.
If you must stay within an Activity, instead of assigning temporary data to items on the Parameter page, prefer Local Variables (from the Parameters tab) to hold state that is not needed outside of the Activity which can be discarded it ends (like your ‘ss’ variable). Otherwise you risk having state ‘stick’ to the parameter page that can unintentionally impact how other rules in that interaction behave.