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 / Patching the current r...
Power Apps
Answered

Patching the current record inside the ForAll function

(0) ShareShare
ReportReport
Posted on by 143

Hello,

 

I'm quite stuck. I know there doesn't seem a way to get the current item in a ForAll loop so that we have to resort to LookUp. 

I already found this answer.

https://powerusers.microsoft.com/t5/Building-Power-Apps/Current-record-inside-the-ForAll-function/td-p/412988

 

The problem is that I need the item from the collection I'm looping over. This code doesn't work:

 

 

ForAll(colTeams,
 ForAll(TimeSlots,
 If(IsBlank(Tijdslot), Patch(Tijdsloten, Defaults(Tijdsloten), LookUp(TimeSlots, 'Zone ID' = TimeSlots[@'Zone ID'])))
 )
)

 

It gives me this error:

Rieus_0-1690827591877.png

This code on the other hand works perfectly:

 

ForAll(colTeams,
 ForAll(TimeSlots,
 If(IsBlank(Tijdslot), Patch(Tijdsloten, Defaults(Tijdsloten), LookUp(TimeSlots, 'Zone ID' = 3)))
 )
)

 

 Please tell me I don't have to rename the column like in this answer:

https://powerusers.microsoft.com/t5/Building-Power-Apps/Reference-Current-Record-of-ForAll/td-p/162054

 

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @Rieus,

     

    When using multiple nested functions that have record scope (Filter, LookUp, AddColumns...), it is advised to use explicit record references for certain loops:

    ForAll(
     colTeams,
     ForAll(
     TimeSlots As Inner,
     If(
     IsBlank(Inner.Tijdslot), 
     Patch(
     Tijdsloten, 
     Defaults(Tijdsloten), 
     LookUp(
     TimeSlots, 
     Inner.'Zone ID' = 'Zone ID'
     )
     )
     )
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Rieus Profile Picture
    143 on at

    Thanks! And ThisRecord is also an option, that's what I used now 🙂
    https://powerapps.microsoft.com/en-us/blog/formulas-thisrecord-as-and-sequence/

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard