Within a Pega Marketing Strategy, say StrategyX, we have a Sub Strategy which can give back multiple pages as a result (as visible in the Test run panel).
Each page contains multiple properties, one of which being a property called ".pyBehaviour". Within our StrategyX we want to check if a certain value, say "valueY", is present in the property .pyBehaviour in one of the pages of the Sub Strategy results and give back 1 if true and 0 if false. Also we don't want to directly input the Sub Strategy into the component, in this example the Set Property component (see screenshot for setup).
By referencing the sub-strategy using the expression Sub_Strategy.pxResults you implicitly only reference the first page returned by the component. The simplest way to achieve your goal is to use standard strategy shapes such as a Filter and Set Property.
Create a Filter called say "Behaviour_Is_Y" and include the expression @equals("valueY", .pyBehaviour)
Join Sub_Strategy to Behaviour_Is_Y
In your Set Property, use the expression: @if(Behaviour_Is_Y.pxRank > 0, 1, 0)
Since you are referencing the Behaviour_Is_Y Filter shape directly by name in the above expression, you will only be testing pxRank for the first page, and so pxRank will be 1 if there are any results, and blank if there are no results.
If your target property is numeric, then you could simply set it to Behaviour_Is_Y.pxRank (without the if condition), because it will default to 0 if .pxRank is blank.
If I understand correctly, in your example we would have to make a filter for each behaviour that could come from our Sub_Strategy if we want to use each of them individually.
To clarify, the example above was merely a simplified version for testing and as an example for this Question. In the future we might have 50-100 behaviours and we don't want to extract them first with individual filters, but we are looking for a solution where we can directly loop over the results from the sub-strategy containing the behaviours to see if they exist.
So say we have 50 behaviours, we want to set all of them as a property in 1 set property block (with multiple items) without having to make 50 set property blocks. In each item we want to be able to check for a different value and set the value to 1 or 0.
For example (also see screenshot attached):
valueX = 0 or 1
By checking for: @if(@IsInPageList("valueX","pyBehaviour",Sub_Strategy.pxResults)==true,1,0)
valueY = 0 or 1
By checking for: @if(@IsInPageList("valueY","pyBehaviour",Sub_Strategy.pxResults)==true,1,0)
valueZ = 0 or 1
By checking for: @if(@IsInPageList("valueZ","pyBehaviour",Sub_Strategy.pxResults)==true,1,0)
Is this possible with the IsInPageList() function or should another method be used here?
Posted: 6 months ago
Posted: 30 Nov 2020 12:55 EST
Chris Hellewell (hellc)
Architect, Next Best Action Strategy Framework
I don't think the function IsInPageList is going to do what you want here, since pxResults does not appear to be a page list within Sub_Strategy. If you check out the properties in Sub_Strategy you will just get the properties in the strategy results page.
A simple way to achieve what you need is to use a Group By shape - say called Check_Behaviour - that's fed by the output from your Sub_Strategy where you set each property you need as follows:
.ValueX = Max @if(@equals("ValueX",.pyBehaviour),1,0)
.ValueY = Max @if(@equals("ValueY",.pyBehaviour),1,0)
The Group By will return a single row with all of your ValueX, ValueY etc. properties set.
You can then refer to these properties anywhere in your strategy using the format Check_Behaviour.ValueX etc.
If you want to persist these properties in the SR you'll need to include a Set Property shape in the logic stream to do that:
.ValueX = Check_Behaviour.ValueX.
.ValueY = Check_Behaviour.ValueY
See attached screen shot for an example of the Group By
Note that this process may be slightly more efficient if your target properties are Boolean (true / false) and the group by settings are:
.ValueX = TRUE IF ANY @equals("ValueX",.pyBehaviour)
.ValueY = TRUE IF ANY @equals("ValueY",.pyBehaviour)