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

Update Multiple Records in SharePoint Based on a Gallery with the Same Data

Dear all,

 

I would like to change the status of several items in SharePoint list from "Submitted" to "Approved" or "Rejected". To do so, I have a filtered Gallery called Gallery7 connected to the SharePoint list as follows:

 

Filter(MasterTS, Email = varRecord, Status ="Submitted")

 

Where:

 

MasterTS: SharePoint list with all the records

varRecord: Email of the person that submitted the data

Status: The column in the MasterTS that I would like to update

 

What formula could I use to update the status of all the items in this Gallery in my SharePoint list? I tried to use ForAll+Patch but I did not manage to make it work. The idea is that when the manager of the person that submitted the data clicks on the "Approved" button, this updates all the records submitted by this person.

 

Thanks in advance for your help.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@sebastiangz7 

You can do this with a ForAll as you mentioned.

Your formula would be the following:

ForAll(
    RenameColumns(Gallery7.AllItems, "ID", "_id"),
    UpdateIf(MsterTS, ID=_id,
        {Status: "Approved}
    )
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

3 REPLIES 3
Super User III
Super User III

@sebastiangz7 

You can do this with a ForAll as you mentioned.

Your formula would be the following:

ForAll(
    RenameColumns(Gallery7.AllItems, "ID", "_id"),
    UpdateIf(MsterTS, ID=_id,
        {Status: "Approved}
    )
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Super User III
Super User III

@sebastiangz7 
The PATCH formula can be used without FORALL to perform bulk updates to SharePoint.  My proposal is to create a table of updates using only the gallery's ID & Status columns and then upsert them.  Doing this requires only 2 arguments to PATCH: target table and updates table.

Put this code in the OnSelect property of the "Approve" button:

Patch(
    your_sharepoint_list,
    UpdateIf(
        ShowColumns(
            Gallery1.AllItems,
            "ID",
            "Status"
        ),
        true,
        {Status: {Value: "Approved"}}
    )
)


Then put this code in the OnSelect property of the "Reject" button.

Patch(
    your_sharepoint_list,
    UpdateIf(
        ShowColumns(
            Gallery1.AllItems,
            "ID",
            "Status"
        ),
        true,
        {Status: {Value: "Rejected"}}
    )
)



Note:  I assumed your Status column was a Choices type in SharePoint.  If its single-line text you will need to modify my formulas


If you want to learn more about Bulk Modifying SharePoint Records you can check out this link: 

Article - https://matthewdevaney.com/patch-multiple-records-in-power-apps-10x-faster/


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

Thanks a lot! I had not used the UpdateIf function before, you saved my day! I spent hours on this 🙂

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (9,916)