cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Patch Multiple Records Using For all and a Filter

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Patch Multiple Records Using For all and a Filter

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Community Champion
Community Champion

Re: Patch Multiple Records Using For all and a Filter

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})))

 

 

Highlighted
Community Support
Community Support

Re: Patch Multiple Records Using For all and a Filter

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: Patch Multiple Records Using For all and a Filter

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.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,548)