cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dimitarvid
Regular Visitor

Problem with patch defaults

Hello,

My problem is with patch(......),Defaults, when i try to create new record to my Azure DB I get error . can you help me this is my code on button.

Patch('[dbo].[OrderDetails]',Defaults('[dbo].[OrderDetails]');{OrdersID: Form2.LastSubmit.OrderID, ProductsID:Gallery5.Selected.Item,Quantity:Gallery5.Selected.Quantity, Size:Gallery5.Selected.Size,UnitPrice:Gallery5.Selected.Price});SubmitForm(Form2)&ResetForm(Form2)&Navigate('Succesful purchase')

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,@v-yutliu-msft

I found the problem. It was in the function code, where a try to patch then submit the form above, so there was nothing to patch. So I now i tried to submit the form first then to patch  the same form. And it worked thank you for the support.

View solution in original post

5 REPLIES 5
v-yutliu-msft
Community Support
Community Support

Hi @dimitarvid ,

Since your formula is related to many other controls, I could not directly give you advice.

Could you tell me:

1)data type of these fields: OrdersID, ProductsID, Quantity, Size, UnitPrice, Item?

2)where do you put this patch function?

3)the relationship between this formula, form2 and gallery5?

4)how do you set gallery5 and form2?

 

 

Best regards,

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

Hello,

 

In SQL OrdersID, ProductID are int, Quantity, Size and Unitprice are nvarchar. Item is from collection and it is not related to the data base.

The patch function is on a button. The relationship between this formula, form2 and gallery5. Is to submit the  data from form2 to table Orders and the data from the gallery5 to table OrderDetails. The data in the gallery i from a PowerApp collection (not sharepoint). And I want to transfer the data from the collection to the table OrderDetails.

Hi @dimitarvid ,

I forgot to mention one key point:

Do you have primary key in your azure db?

If you do not have primary key in the sql table, the table will be read-only in powerapps.

 

 

Best regards,

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

Hello,

 

Yes I have primary keys in table Orders ->OrderID in table OrderDetails - > OrderDetailsID.

Hello,@v-yutliu-msft

I found the problem. It was in the function code, where a try to patch then submit the form above, so there was nothing to patch. So I now i tried to submit the form first then to patch  the same form. And it worked thank you for the support.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (46,626)