cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AndiRodi
Level: Powered On

Patch function doesn't work in SQL DB

Hi to everyone,

i have an issue with the function Patch().

My scenario:

i connect my PowerApps app to a SQL DB (SQLEXPRESS) to manage customer data. What i need is to write a new record in '[dbo].[Customer]' which include the customer data (for exemple, FirstName and LastName). a botton of PowerApps should upgrade an existing record on my table '[dbo].[Customer]' when the user presses it.

Into the OnSelect propriety i typed Patch('[dbo].[Customer]';LookUp('[dbo].[Customer]';CustomerID=1);{FirstName:"Aldo";LastName:"Cotechino"}) but an error message tell me that the Patch() function is waiting as a first parameter a collection (WHY?'[dbo].[Customer]' is a db table, so is a collection). the same happens if i want to write a new recordo on '[dbo].[Customer]' typing into the OnSelect propriety Patch('[dbo].[Customer]';LDefaults('[dbo].[Customer]');{FirstName:"Aldo";LastName:"Cotechino"}) .

 

can someone let me know why this happen? did i do a mistake somewhere?

 

Thanks,

 

Andi

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Patch function doesn't work in SQL DB

Hi @AndiRodi ,

 

Could you please check whether you have set your CustomerID as Primary Key in your SQL table?

 

Best Regards.

Yumia

 

2 REPLIES 2
Highlighted
Eloy
Level: Powered On

Re: Patch function doesn't work in SQL DB

Hi @AndiRodi ,

First I noticed you have semicolons in the Patch() function. The Arguments in the Patch function are separated by comas , .

 

try this

Patch('[dbo].[Customer]',   First(    Filter('[dbo].[Customer] ', CustomerID=1)   ), {FirstName: "Aldo, LastName: "Cotechino"}  )

The Patch Function signature is as follows for updating Records   Patch(datasource, Filter record to Update, {field values to update} )

 

Hope this helps!

Community Support Team
Community Support Team

Re: Patch function doesn't work in SQL DB

Hi @AndiRodi ,

 

Could you please check whether you have set your CustomerID as Primary Key in your SQL table?

 

Best Regards.

Yumia

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Users Online
Currently online: 40 members 4,843 guests
Please welcome our newest community members: