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

Need help speeding up forAll patch

Hi, I've got a patch function that updates a single field in some items in the CDS.

Currently, its I'm told it's too slow with about 16 items being patched.

 

This is the code:

 

ForAll(
    Categories_Gallery.AllItems,
    ForAll(Items_Gallery.AllItems,
        Patch(
        [@Items],
        LookUp([@Items], Name = ItemNameLbl.Text),
            {
                Inspection_result: InspectionResultRadio.Selected.Value
            }     
        );
    )
);

 

 

The items are inside a gallery, which is inside of a gallery of categories.

It gets every item from its gallery and then patches it. Right now, it takes about 5 seconds to do this and then navigate away from the screen.

 

Is there any way to make this faster? I was looking at concurrent() to split up the patch but the gallery has a variable amount of categories and items in it, so I don't think that would work.

4 REPLIES 4
Super User III
Super User III

@Mikkiel 

What is the name of your Primary Key in the CDS table?  Is it found in your gallery?  If yes, tell me the column name and  I can show you how to patch multiple records at once using the 'FAST PATCH' method.  Below is a preview of how I do it.  Please let me know the answer to my questions and I'll help you out.

 

Syntax:

Patch(your_datasource_name, your_collection)


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

The primary key for the Categories is item_categoryid and for the items is itemid.

These are not currently used in the galleries, but both primary name fields are.

@Mikkiel 
You'll need to include the primary key in your gallery.  It doesn't need to be shown as a label.  It just needs to be included in the record.  Once you have done this let me know.

 

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

Sorry for the late reply, I wasn't able to work on the powerapp until now.

 

I have included both primary keys in the galleries, I've just added them as labels and hidden them.

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 (8,001)