cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Daveed73
Advocate I
Advocate I

Updating multiple records in a Shartepoint list using Patch

 

I have a PowerApp which saves data to a Sharepoint list called Beds In. Within the PowerApp there is a second part to it whereby I need to save a name to each of the records in the Sharepoint list where the unique reference field matches.

 

I have tried this to look for each of the REF fields that match but it only updates the first instance it finds and not all instances.

 

 

Patch('Beds In', LookUp('Beds In',Ref=ESF_Ref.Text), { Print_Name: ESF_PrintName.Text } );

 

Any ideas how I can make this work so that for each record where Ref = ESF_Ref.Text it updates the Print_Name field with the value in ESF_PrintName.Text

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

Hi @Daveed73,

 

What is your current situation?

 

To update multiple records, we could either take use of the forall function, or the UpdateIf () function.

 

ForAll first:

Forall('Beds In', 
     If(Ref=ESF_Ref.text, 
         Patch('Beds In', 
                   LookUp('Beds In',Ref=ESF_Ref.Text), 
                   { Print_Name: ESF_PrintName.Text } )
        )
)

With the UpdateIf function, the formula should be:

UpdateIf('Beds In', Ref=ESF_Ref.text, {Print_Name: ESF_PrintName.Text})

Regards,

Michael

Community Support Team _ Michael Shao
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
Shanescows
Super User
Super User

You are going to need to use ForAll in conjunction to loop through all the records. Check out this video I did on Repeating Tables. I do very similiar to what you want to do, just in a different context. My save button loops through all of the records and creates them, you would just need to look through and edit.

 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training
v-micsh-msft
Community Support
Community Support

Hi @Daveed73,

 

What is your current situation?

 

To update multiple records, we could either take use of the forall function, or the UpdateIf () function.

 

ForAll first:

Forall('Beds In', 
     If(Ref=ESF_Ref.text, 
         Patch('Beds In', 
                   LookUp('Beds In',Ref=ESF_Ref.Text), 
                   { Print_Name: ESF_PrintName.Text } )
        )
)

With the UpdateIf function, the formula should be:

UpdateIf('Beds In', Ref=ESF_Ref.text, {Print_Name: ESF_PrintName.Text})

Regards,

Michael

Community Support Team _ Michael Shao
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

nvpc
Helper I
Helper I

I was looking to do the same, update multiple records on a SP list using Patch, the following code is working for me but i'm wondering if this is efficient as am creating a collection and then filtering the table to update the records;

//*************************************************

      ClearCollect( A,

                   Filter(Vacancies_Information, PO_ID = varDeptNumber And Rejected = false And IsBlank(FirstDateSubmittedToDept) )

      );

            //**** udpate all records in the collection ********

        ForAll(A,

            Patch(Vacancies_Information,

                            LookUp(Vacancies_Information,PO_ID = varDeptNumber And Rejected = false And IsBlank(FirstDateSubmittedToDept)),

              {ASHPSubmittedtoDeptbyPODate: Now()},

              {FirstDateSubmittedToDept:Now()},

              {Locked:true},

              {Submitted:true}

            )

        )

      //********************************************

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (56,577)