After having finished the Activity exercise in the SSA course the behavior of the Loop construct got me thinking...
On my RequestAssets section I've created two separate grids holding:
- Current (read-only) list of assets from D_AssetList data page
- An editable grid referring to a Assets page list for extending these with new assets
My post-processing run activity should loop over .Assets on the Clipboard; which are of the same class (SAE-HRServices-Data-Assets). Is it correct to define a Loop with "Repeat For Each Page"? What's the purpose of "Step Page" when I define a Loop and why isn't this text box disabled when the documentation states "Leave the Step Page field blank."?
- How do I tell PRPC to specifically loop over this Clipboard page instead of D_AssetsList which is of identical class?
Tracing shows me it iterates over the wrong page list somehow holding all twenty-something assets instead of the one or two I'd like to add. I would rather implement logic that iterates over the rows in a separate grid than relying on the "OnlyIfNew" parameter of Save-Obj.
- How do I test whether a page list actually has items (children) or is empty? Does it matter whether those children are plain properties or embedded pages?
In pyWorkPage is see one page named Asset, but it has no contents. I try to make good use of "Enable conditions before this action", but any precondition still results in a pyCommitError. I assume the Steps in this loop still get executed. This is why I would like to learn to common practice from the available library functions for testing an possibly empty set or properties.
You almost never would use “For each page”. In most situations you would use “For each embedded page”. When using this looping option, within the “step page” field you are required to specify a Page-type List Property. A Page-type List Property is either a PageGroup, such as .pyWorkParty, or in your case a PageList such as .Assets.
Your Activity runs in the context of a pre-existing step page – for example “pyWorkPage” – so you do not need to say “Primary.Assets”. And you should avoid hard-coding a page name such as “pyWorkPage” – it is unnecessary. This is the same concept as Object-oriented Programming where methods are executed in the context of the Object’s “this” reference.
In your screenshot you configured a loop but did not enter anything in the “step page” field so you either used “For each page” or a “for 1-to-N” counted loop. If you want to call an Activity inside the loop and want the called Activity’s step page to remain “Primary” you would use “for 1-to-N” but then would need to pass the loop index to that Activity to tell it what data to process, e.g., .Assets(param.LoopIndex). When looping, the loop counter is param.pyForEachCount. Be very careful not to define a look within a loop as param.pyForEachCount will overwrite itself.
To test whether a List is empty you would all a Function such as @SizeOfPropertyList(). The argument to the Function can be any List Property such as .Assets, D_AssetsList.pxResults, .pyWorkParty, or even a ValueList Property.