Scenario: I have 2 collections.
Collection A { name: string , age: int }
Collection B { name: string, address: string }
If I try to loop through Collection A (using ForAll), and then use a LoopUp to search Collection B by comparing names are equal, such as the below -
ForAll('Collection A', CustomFunctionDoSomething.Run(LookUp('Collection B', name=ThisRecord.name).address))
The above will always return the very first record from Collection B for all records in Collection A.
Resulting in all names having the same address.
I have thought about the reasons why, but nothing makes sense, is this a bug?
Hi @power-apps-user
It's not a bug, actually it includes concept of scope that when we use nested functions with ForAll such as Patch(), Collect() or If condition etc. then it cannot find the reference from outer scope. That is the reason we need to use either As or "Collection[@column]".
Please refer to the below link for the same.
https://powerapps.microsoft.com/en-us/blog/formulas-thisrecord-as-and-sequence/
Thanks!
Inogic Professional Services Division
Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!
Drop an email at crm@inogic.com
Services: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
Hello Inogic,
My solution was to use 'As', which fixes this issue. However this took a few hours of testing before I found the problem and solution. i.e. -
ForAll('Collection A' As _ColA, CustomFunctionDoSomething.Run(LookUp('Collection B', name=_ColA.name).address))
My intention above was to find out if this issue was my incorrect knowledge of how ThisRecord works, or that this was a bug.
Hi @power-apps-user
You can try below formula for forall in your canvas app,
ForAll('Collection A', CustomFunctionDoSomething.Run(LookUp('Collection B', name=CollectionA[@name]).address))
Thanks!
Inogic Professional Services Division
Power Platform and Microsoft Dynamics 365 CRM Development – All under one roof!
Drop an email at crm@inogic.com
Services: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
WarrenBelz
89
Most Valuable Professional
MS.Ragavendar
60
stampcoin
48