Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Current record inside the ForAll function

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.

  • Anonymous_Hippo Profile Picture
    Anonymous_Hippo 1,247 on at
    Re: Current record inside the ForAll function

    @mdevaney Very helpful 🙌  thanks!!

  • Verified answer
    mdevaney Profile Picture
    mdevaney 30,012 on at
    Re: Current record inside the ForAll function

    @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."

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard