cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
balys
Frequent Visitor

Patch/Update functions do not work provide different errors.

Backstory: 

I have a Table named Settings - columns: SettingName, SettingValue

balys_2-1642604839006.png

 

Task: with a button push update a SQL Table colum SettingValue

 

I run several commands: 

Patch( 'Settings', Lookup( 'Settings', 'SettingName' = "EnableAllDiagnostics" ), { 'SettingValue': "1" } )

balys_0-1642604672114.png

Update(Settings,
First( Filter( Settings, SettingName="EnableAllDiagnosticPolicies" ) ), { SettingName: "EnableAllDiagnosticPolicies" ,
SettingValue: "0" } )

balys_1-1642604819013.png

 

I am new to PowerApps and I think I do a simplest mistake, could someone point me to that mistake? 

Thanks in advance 

Balys

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@balys 

Your first error is because you spelled LookUp incorrectly - that is the simple one.

 

Your formula is better done with an UpdateIf function.

It would be:

UpdateIf(Settings, SettingName="EnableAllDiagnostics", {SettingValue: "1"})

 

Same for your second formula:

UpdateIf(Settings, SettingName="EnableAllDiagnosticPolicies", {SettingValue: "0"})

Avoid using First(Filter - It is equivalent to LookUp except that with First(Filter PowerApps will filter ALL rows of your data and then just return one row.  With LookUp, it will return the first record it finds.  So it is much more performant.

 

I hope this is helpful for you.

 

 

 

_____________________________________________________________________________________
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

8 REPLIES 8
Nogueira1306
Super User
Super User

Your table does not have any item the name: EnableAllDiagnostics

That is the error. It is not finding nothing beacause you dont have a setting in your SQL Tble with that name...

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Last Post on Community

My website!

PowerSoumyo
Frequent Visitor

Where are you writing this expression? OnSelect of a button? Are there other formulae in this same action? Have you made any structural changes to the table in the SQL database (renaming/adding/removing columns/tables)?

RandyHayes
Super User
Super User

@balys 

Your first error is because you spelled LookUp incorrectly - that is the simple one.

 

Your formula is better done with an UpdateIf function.

It would be:

UpdateIf(Settings, SettingName="EnableAllDiagnostics", {SettingValue: "1"})

 

Same for your second formula:

UpdateIf(Settings, SettingName="EnableAllDiagnosticPolicies", {SettingValue: "0"})

Avoid using First(Filter - It is equivalent to LookUp except that with First(Filter PowerApps will filter ALL rows of your data and then just return one row.  With LookUp, it will return the first record it finds.  So it is much more performant.

 

I hope this is helpful for you.

 

 

 

_____________________________________________________________________________________
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!
RandyHayes
Super User
Super User

@balys 

I should add...the formulas provided are for Updating records - not for creating them.

If you need that ability, let me know and I will provide more details.

_____________________________________________________________________________________
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!

Hello Goncalo,

I am thankful for your insights! 

Now I get another error: 

balys_0-1642680314219.png

 

Remove all the '

 

 

balys
Frequent Visitor

It worked with LookUp

balys
Frequent Visitor

You were right, it worked with LookUp  - Speling issue 

And Gonçalo was also right - EnableAllDiagnosticPolicies was also spelled incorrectly

Helpful resources

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

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,723)