Backstory:
I have a Table named Settings - columns: SettingName, SettingValue
Task: with a button push update a SQL Table colum SettingValue
I run several commands:
Patch( 'Settings', Lookup( 'Settings', 'SettingName' = "EnableAllDiagnostics" ), { 'SettingValue': "1" } )
Update(Settings,
First( Filter( Settings, SettingName="EnableAllDiagnosticPolicies" ) ), { SettingName: "EnableAllDiagnosticPolicies" ,
SettingValue: "0" } )
I am new to PowerApps and I think I do a simplest mistake, could someone point me to that mistake?
Thanks in advance
Balys
Solved! Go to Solution.
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.
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!
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)?
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.
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.
Hello Goncalo,
I am thankful for your insights!
Now I get another error:
Remove all the '
It worked with LookUp
You were right, it worked with LookUp - Speling issue
And Gonçalo was also right - EnableAllDiagnosticPolicies was also spelled incorrectly
User | Count |
---|---|
122 | |
87 | |
86 | |
75 | |
67 |
User | Count |
---|---|
214 | |
180 | |
137 | |
96 | |
83 |