web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch slow performance...
Power Apps
Unanswered

Patch slow performance with lookup

(0) ShareShare
ReportReport
Posted on by 2

Hello and thanks for a tip. I read many things about patching, but this patch in my powerapp is verry slow, maybe it can be faster...

It patches a collection to a sharepoint list...is there a way to do it faster...for 30 items it takes one minute and more.

 

Thank you verry much and greatings

 

Jim

 

ForAll(Filter(BesArtCollection; id = -1) As BAC;
// new bestellartikel
UpdateIf(BesArtCollection;
i = BAC[@i];
{id:
Patch(BestellArtikel; Defaults(BestellArtikel);
{//ArtikelID: Utils.Querverweis(LookUp(Artikelsammlung; Title = BAC[@Title]).ID);
ArtikelID: LookUp(Choices(BestellArtikel.ArtikelID); Id=LookUp(Artikelsammlung; Title = BAC[@Title]).ID);
//BestellID: Utils.Querverweis(OrderID);
BestellID: LookUp(Choices(BestellArtikel.BestellID); Id=OrderID);
Menge: BAC[@Menge];
BesArt_Preis: BAC[@Preis];
Notizen: BAC[@Notizen]}
).ID
}
)
);;

Categories:
  • SBax Profile Picture
    1,348 on at

    Hi @powersmile 

     

    Have a look at the approach described by Matthew Devaney in this blog post

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @powersmile 

    Your performance will always be horrible when you use a ForAll like a for loop.

    Your formula has the ForAll backward. You are trying to use it like a ForLoop in some development language - which PowerApps is not.  ForAll is a function that returns a table of records based on your iteration table and record schema.

    It is more efficient to use the function as intended and will provide better performance.

     

    Please consider changing your Formula to the following:

    Patch(BestellArtikel;
     ForAll(Filter(BesArtCollection; id = -1) As _item;
     {
     id: Blank();
     ArtikelID: LookUp(Choices(BestellArtikel.ArtikelID); Id=LookUp(Artikelsammlung; Title = _item.Title).ID);
     BestellID: LookUp(Choices(BestellArtikel.BestellID); Id=OrderID);
     Menge: _item.Menge;
     BesArt_Preis: _item.Preis;
     Notizen: _item.Notizen
     } 
     )
    )

    It is assumed that id is the primary key column of your data in the above.

     

    If there is some reason why you would then try to maintain a totally separate in-memory version of your data in a collection, then you can capture the results of this (which will be a table) and it will have all the new id's.

     

    I hope this is helpful for you.

  • powersmile Profile Picture
    2 on at

    Hello RandyHayes,

     

    thanks for your great code....it works so fast, but I had to comment out "ID: Blank()", but it seems to work great. Before this patch I have a other Patch to update existing items, could you help me please to update this code.

     

    Thank you verry much

     

    Part 1 -> update Artikel if they are changed

    Part 2 -> for a new order, to patch new article (your code, that works great)

     

    //updateArtikel

    ForAll(Filter(BesArtCollection; id <> -1) As BAC;
    // update entry with this ID in sharepoint list
    // make sure that it belongs to this order
    If(OrderID <> LookUp(BestellArtikel; ID = BAC[@id]; BestellID).Id;
    Notify("Fehler! [Code: 100]"; NotificationType.Error);;
    If(DEBUG;Notify(BAC[@i] & " " & BAC[@Title] & " " & BAC[@id]; NotificationType.Error));;
    Blank();//Blank nur damit die Typen stimmen
    UpdateIf(BestellArtikel;
    ID = BAC[@id];
    {ArtikelID: LookUp(Choices(BestellArtikel.ArtikelID); Id=LookUp(Artikelsammlung; Title = BAC[@Title]).ID);
    Menge: BAC[@Menge];
    BesArt_Preis: BAC[@Preis];
    Notizen: BAC[@Notizen]
    }
    )
    )
    );;

    Patch(BestellArtikel;
    ForAll(Filter(BesArtCollection; id = -1) As _item;
    {
    //id: Blank();
    ArtikelID: LookUp(Choices(BestellArtikel.ArtikelID); Id=LookUp(Artikelsammlung; Title = _item.Title).ID);
    BestellID: LookUp(Choices(BestellArtikel.BestellID); Id=OrderID);
    Menge: _item.Menge;
    BesArt_Preis: _item.Preis;
    Notizen: _item.Notizen}
    )
    );;

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard