Hi
I'm hoping someone can give me a steer - I'm pretty sure this is simple, but I have made it difficult 😕
I have built an app and am currently trying to complete the last element. I'm stuck on trying to shape/filter my collection within a ForAll step, which passes each batch of filtered data as an input parameter to a flow. I'm OK with the flow / passing the parameters/JSON etc and had this all working fine. It's just now when I try to compile and pass more input parameters, I'm struggling with the shaping of this added data etc.
In the app, users can select multiple recipients from multiple orgs and in doing so create a collection (Collection1) like the following:
Org | User |
Org1 | UserA |
Org1 | UserB |
Org2 | UserC |
Org2 | UserD |
Org2 | UserE |
As part of my flow, I want to pass the details for each org as a separate run i.e. Flow run 1 for just Org 1 users, Flow run 2 for just Org 2 users etc etc
I 'thought' the easy way to shape the data like that was to create a distinct collection of the Orgs (Collection2) and use this as the source in a Forall action, which would loop through each org and filter Collection1 based on the current value in the ForAll loop. Using the distinct function, Collection2 looks like this:
Result |
Org1 |
Org2 |
Though, when I try to do this I cannot seem to get 'ThisRecord.Result' in the ForAll source loop to present inside the filter function within my ForAll. ThisRecord inside the Filter loop defaults to ThisRecord of Collection1 instead of Collection2.
Any advice would be much appreciated.
Thank you.
Solved! Go to Solution.
Sounds like you need to consider GroupBy instead of distinct.
Consider the following:
ForAll(GroupBy(yourCollection, "Org", "_recs"),
yourFlow.Run(JSON(_recs))
)
Of course, the above completely hypothetical based on what you mention in the post, but the concept is, Group the collection by the Org. The _recs column result will then have all of the Users for that Org in it. So, you are just simply referencing the _recs table to get what you need.
I hope this is helpful for you.
Sounds like you need to consider GroupBy instead of distinct.
Consider the following:
ForAll(GroupBy(yourCollection, "Org", "_recs"),
yourFlow.Run(JSON(_recs))
)
Of course, the above completely hypothetical based on what you mention in the post, but the concept is, Group the collection by the Org. The _recs column result will then have all of the Users for that Org in it. So, you are just simply referencing the _recs table to get what you need.
I hope this is helpful for you.
@RandyHayes - Perfect, many thanks for this. Exactly what I needed (along with some free education on the groupby function.. 👍)
Always happy to help!