cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AnthonyPhan
Level 8

Patch problems with on premises SQL gateway

Hi, 

 

I have a button which will create a new row in my Datasource. The datasource is an on premises gatway to an SQL server. I decided to use the patch funcation to do this becuase it has worked in previous apps where the datasource is an online Sharpoint List. I recieve the following error "First argument of 'Patch' should be a collection", however this error does not occure if i set the datasource to a sharepoint list. 

 

Patch( '[db_owner].[ResourceEstimationTimeSheetCPY]', Defaults('[db_owner].[ResourceEstimationTimeSheetCPY]'), {Email: "123@gmail.com"}  )

I have attached the following screenshor for your reference:

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Patch problems with on premises SQL gateway

Hi @AnthonyPhan,

 

To have patch function work, if the primary key has the identity specification set to YES (thread reference: https://powerusers.microsoft.com/t5/General-Discussion/DataSource-GUID-not-auto-generated-when-creat...), then there is no need to include the primary key column, otherwise, the column set to Primary key must be included in the record.

 

For more information about patch function, see:

Patch function in PowerApps

https://docs.microsoft.com/en-us/powerapps/functions/function-patch

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
Community Support Team
Community Support Team

Re: Patch problems with on premises SQL gateway

Hi @AnthonyPhan,

 

To have patch function work, if the primary key has the identity specification set to YES (thread reference: https://powerusers.microsoft.com/t5/General-Discussion/DataSource-GUID-not-auto-generated-when-creat...), then there is no need to include the primary key column, otherwise, the column set to Primary key must be included in the record.

 

For more information about patch function, see:

Patch function in PowerApps

https://docs.microsoft.com/en-us/powerapps/functions/function-patch

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AnthonyPhan
Level 8

Re: Patch problems with on premises SQL gateway

It @v-monli-msft thank you for you reply. Your response was very helpful. Turns out the issue was I had no primary key colum defined for my particular SQL table. I had to drop the table and recreate it with a primary key column

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

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

Top Kudoed Authors
Users Online
Currently online: 187 members 5,387 guests
Please welcome our newest community members: