web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / (confusion) ThisRecord...
Power Apps
Answered

(confusion) ThisRecord when used in a LookUp to evaluate an expression keeps returning the first record.

(0) ShareShare
ReportReport
Posted on by 29

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?

Categories:
I have the same question (0)
  • Inogic Profile Picture
    1,283 Moderator on at

    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/




  • power-apps-user Profile Picture
    29 on at

    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.



  • Verified answer
    Inogic Profile Picture
    1,283 Moderator on at

    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/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,041

#2
11manish Profile Picture

11manish 676

#3
Valantis Profile Picture

Valantis 655

Last 30 days Overall leaderboard