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

You were right, it worked with LookUp  - Speling issue 

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

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 (2,753)