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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch Multiple Records...
Power Apps
Answered

Patch Multiple Records Using For all and a Filter

(0) ShareShare
ReportReport
Posted on by 17

Hi,

 

I am creating an app that lists tasks of 2 types of shutdown. I am using Patch to update each record as they are completed.  What I am trying to do now is essentially 'reset' the sharepoint list for each type of shutdown so that it can be used for the next shutdown.

I am trying to filter the list by shutdown type then patch the Completed column and Task Completed column so that they say false.

So I am filtering a data source by one column, then patching all the records that the filter returns.

 

This is what I have so far...

 

ForAll('Pilot TC San', (Patch('Pilot TC San',LookUp('Pilot TC San',Shutdown=Dropdown1.Selected.Result),{Completed:false,TaskComplete:False})))

 

Dropdown.Selected.Result is the type of shutdown that is to be reset.

 

I get an error which states 'This Function cannot operate on the same data source that is used in the ForAll function'.

 

Any help on this would be much appreciated

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    If the filtering is done in a Gallery or  a Collection, the Use the Gallery or Collection name ForAll instead of the table name:


    ForAll(CollectionName, (Patch('Pilot TC San',LookUp('Pilot TC San',Shutdown=Dropdown1.Selected.Result),{Completed:false,TaskComplete:False})))

     

     

  • Verified answer
    v-xida-msft Profile Picture
    on at

    Hi @AllyCrop ,

    Could you please share a bit more about your scenario?

    Do you want to update the Completed column and Task Completed column of all related records in your data source based on the shutdown type specified within the Dropdown1?

     

    Based on the error message that you mentioned, I think there is something wrong with your formula. You could not specify same data source within the Patch function as that within your ForAll function. I assume that you used a Gallery control in your app to list all records from your SP List, and you connect the Gallery to your 'Pilot TC San' List data source, is it right?

    Please modify your formula as below:

    ForAll(
     Gallery1.AllItems, 
     Patch(
     'Pilot TC San',
     LookUp('Pilot TC San',Shutdown = Dropdown1.Selected.Result),
     { 
     Completed: false,
     TaskComplete: false
     }
     )
    )

     

    Actually, I think it is not necessary to use ForAll function to achieve our needs, instead, I think the UpdateIf function is enough. Please consider take a try with the following formula:

    UpdateIf(
     'Pilot TC San',
     Shutdown = Dropdown1.Selected.Result,
     {
     Completed: false,
     TaskComplete: false
     }
    )

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

  • AllyCrop Profile Picture
    17 on at

    The UpdateIf worked a treat, thank you. It wasn't a function I was aware of, so I was overcomplicating it by using functions I knew about.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 445

#2
WarrenBelz Profile Picture

WarrenBelz 386 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 321 Super User 2025 Season 2

Last 30 days Overall leaderboard