cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mikkiel
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
mdevaney
Super User
Super User

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

Mikkiel
Frequent Visitor

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

Mikkiel
Frequent Visitor

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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,169)