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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Delegation warning com...
Power Apps
Answered

Delegation warning comparing lookup column value and label text

(0) ShareShare
ReportReport
Posted on by 109

I currently have a submit button that uses the forAll() function to parse through a gallery and patch a new, or existing, record. Without having a surefire way to reference each cells "ThisItem" variable I'm using a lookup with multiple conditions to ensure that the patch is going to the correct record. I'm running into an issue when trying to compare a lookup column value to a cells label text. Here's the following code:

 

ForAll(
 main_gallery.AllItems,
 Patch(
 'My Table',
 LookUp(
 'My Table',
 Customer.'Customer Name' = customerName &&
 'Date Audited' >= startThisMonth && 'Date Audited' <= endThisMonth &&
 Product.'Product Name' = cell_product_label.Text
 ),
 {
 Customer: LookUp('SAM Customers', 'Customer Name' = customerName),
 Product: LookUp('SAM Products', 'Product Name' = cell_product_label_MA.Text)
 }
 )
);

 

 I'm getting delegation warnings on line 9 and 13. Is there some way to avoid these?

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @mqcp 

    To start, 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.

     

    You most likely have the primary key of the record in your gallery already and can reference it from your formula.

    The formula would look more like this:

    Patch('My Table',
     ForAll(main_gallery.AllItems,
     {
     yourPrimaryKeyColumn: yourPrimaryKeyColumn,
     Customer: LookUp('SAM Customers', 'Customer Name' = customerName),
     Product: LookUp('SAM Products', 'Product Name' = cell_product_label_MA.Text)
     }
     )
    );

    This will all be dependent on the Items property of your main_gallery control.  As well, this will all be dependent on the correct column names - replace with the primary key name.

     

    I hope this is helpful for you.

  • mqcp Profile Picture
    109 on at

    @RandyHayes One issue I'm running into with this method is I have an autosave feature tied to the inputs in my gallery. So instead of it writing to the already existing record it's just creating a new one. Is there any way to implement the updating form of Patch() into your method?

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

    @mqcp 

    Can you explain more about what you mean by "autosave feature"?  

  • mqcp Profile Picture
    109 on at

    @RandyHayes Each gallery cell has a text input. In each inputs onChange formula I'm patching the value of the input to my table along with an 'incomplete' flag value. Essentially what my submit button does is toggle the flag value of each record in the gallery to 'complete'. This ensures that if the users exits the program on accident, or goes to another page, their progress will be saved. 

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

    @mqcp 

    So, that is a lot of data transactions.  You might want to consider more of a timed bulk save of the gallery items.  Just a thought to reduce the amount of drag on performance.

     

    Either way though, all of what I provided you should be working fine. (in fact, it is that formula that I would put on a timer OnEnd action to autosave periodically)

     

    What problem are you having with that?

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard