cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrstian89
Helper V
Helper V

Patch LookUp = Delegation Warning

Hi!
I am trying to Patch a LookUp column inside a ForAll, but I get delegation warning for this:

my_lookup:  LookUp(lookupTable,Firm = dropdown.Firm)

 

No delegation warning: 

my_lookup:  LookUp(lookupTable,Firm = "Company")

 

The Items of the DropDown:

Sort(Filter(lookupTable,*my filter*).Firm,Firm,Ascending)

 

I have tried making a label with the text value of the dropdown with no help.

 

Since it is within a ForAll, I am not able to set a variable.


Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@mrstian89 

A couple of things...

1) You are already looking up the records of the esc_Plants_Installators table in your combobox, so why do a Lookup again in your formula?  The combobox already has the record.

2) You are referencing ThisItem in your formula...is this formula in a Form or Gallery?

3) For Patch to work properly, you only need to provide the primary key and any change information in the record supplied.  If a primary key is not provided, then patch will create a record.

 

So given a couple of the above points, your formula should be more like this:

Patch('esc_Plants_Installator_Bemyndiget',
    ForAll(Filter(InstBem_Table.AllItems, Inst_Change_1),
        {
            yourPrimaryKeyName: yourPrimaryKeyName,
            crd27_instbemyndigetepost: TrimEnds(Inst_Epost_1.Text),
            crd27_instbemyndigetstilling: TrimEnds(Inst_Stilling_1.Text),
            crd27_instbemyndigettlf: TrimEnds(Inst_Tlf_1.Text),
            platform_lookup: LookUp(esc_Plantss, Platform = ThisItem._platform),
            installator_lookup: ComboBox3.Selected.esc_Plants_Installator
        }
    )
);

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@mrstian89 

ForAll is not a For Loop like in some development language.  It is a function that produces a table.  That table can then be provided to your patch function.

 

What is your entire formula?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Gallery Items (InstBem_Table)

Sort(Filter(esc_Plants_Installator_Bemyndiget, platform_lookup.Platform = varSelectedAsset.Platform),'InstBemyndiget Navn',Ascending)

Combobox3 with the items I want to patch:

Sort(Filter(esc_Plants_Installators,platform_lookup.Platform = varSelectedAsset.Platform),Installator_Firma,Ascending)

Button for patching changes:

ForAll(
    Filter(
        InstBem_Table.AllItems, Inst_Change_1),
            Patch([@'esc_Plants_Installator_Bemyndiget'],ThisRecord,
                {
                    
                    crd27_instbemyndigetepost: TrimEnds(Inst_Epost_1.Text),
                    crd27_instbemyndigetstilling: TrimEnds(Inst_Stilling_1.Text),
                    crd27_instbemyndigettlf: TrimEnds(Inst_Tlf_1.Text),
                    platform_lookup: LookUp(esc_Plantss, Platform = ThisItem._platform),
                    installator_lookup:  LookUp(esc_Plants_Installators,esc_Plants_Installator = ComboBox3.Selected.esc_Plants_Installator)
                    }
                )
            );

 

= ComboBox3.Selected.esc_Plants_Installator

 

The bold underlined part of the patch code has the following error:

Delegation warning. The highlighted part of this formula might not work correctly with column: "ComboBox3.Selected.esc_Plants_Installator" on large data sets.

 

If I replace the combox with a "Text string", it works fine.

Since it is not possible to set a variable inside a ForAll, I am a bit lost on how to remove the delegation warning.

RandyHayes
Super User
Super User

@mrstian89 

A couple of things...

1) You are already looking up the records of the esc_Plants_Installators table in your combobox, so why do a Lookup again in your formula?  The combobox already has the record.

2) You are referencing ThisItem in your formula...is this formula in a Form or Gallery?

3) For Patch to work properly, you only need to provide the primary key and any change information in the record supplied.  If a primary key is not provided, then patch will create a record.

 

So given a couple of the above points, your formula should be more like this:

Patch('esc_Plants_Installator_Bemyndiget',
    ForAll(Filter(InstBem_Table.AllItems, Inst_Change_1),
        {
            yourPrimaryKeyName: yourPrimaryKeyName,
            crd27_instbemyndigetepost: TrimEnds(Inst_Epost_1.Text),
            crd27_instbemyndigetstilling: TrimEnds(Inst_Stilling_1.Text),
            crd27_instbemyndigettlf: TrimEnds(Inst_Tlf_1.Text),
            platform_lookup: LookUp(esc_Plantss, Platform = ThisItem._platform),
            installator_lookup: ComboBox3.Selected.esc_Plants_Installator
        }
    )
);

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,996)