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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,492)