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 / Current record inside ...
Power Apps
Answered

Current record inside the ForAll function

(0) ShareShare
ReportReport
Posted on by 30

Hi, I would like to ask you something,

 

My question is more general. How to work with the current record which is processing in the ForAll loop. I'm quite stuck with that.

 

for better imagination lets assume that I have ForAll function in that function I need to let's say patch record. I need id of the current record in the for all function to use it in the patch function.

Categories:
I have the same question (0)
  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @romber 

    Sure we can do an example together 🙂

     

    In the example our goal is to update several records currently having a Status of "Open" to the Status "Closed".  We already have the ID of all records we want to update stored in a Collection called myRecords.  See my sample code below.

     

    ClearCollect(
     myRecords,
     {ID:1001},{ID:1201},{ID:1315},{ID:1467},{ID:1500}
    );

     

    To perform the patch we can use use this code.  Do you notice how I have referenced the current ID being looped over by writing myRecords[@ID].  This technique is called disambiguation.  The column ID exists in both myRecords and mySharePointList so we  must tell PowerApps to look at myRecords using the square brackets otherwise it will just look at the ID column for the current scope of LOOKUP which is mySharePointList. 

     

    ForAll(
     myRecords,
     Patch(
     mySharePointList,
     LookUp(mySharePointList, ID: myRecords[@ID]),
     {Status: "Closed"}
    );

     

    Let me know if you have any further questions.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Anonymous_Hippo Profile Picture
    1,247 Super User 2024 Season 1 on at

    @mdevaney Very helpful 🙌  thanks!!

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard