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