web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Powerapps Patch to dat...
Power Apps
Unanswered

Powerapps Patch to dataverse

(0) ShareShare
ReportReport
Posted on by 6

Hi

 

I want my shopping cart create a row in my dataverse table when I click on Buy:

KarimBel_0-1710598346925.png

But when i click to buy, I get copies in my table of the first shopping cart:

KarimBel_1-1710598400447.png

This is my formula under button Buy:

ForAll('colShoppingCart',Patch('ShoeOrdersTables', Defaults('ShoeOrdersTables'), {QTY:Value(TextInput2.Text),Name:txtName.Text, ProductName:Title4.Text, Address:txtAddress.Text,Comment:txtComment.Text,TotalPrice: With({ST: Sum(colShoppingCart, Total)}, ST + ST*0.21 + 4.99)}));

Reset(txtName);Reset(txtAddress);Reset(txtComment);Clear(colShoppingCart);

Navigate(OrderConfirmation)
 
Can anyone help me what I have done wrong?
 
Thanks
 
Grtz
Categories:
I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,674 Super User 2024 Season 1 on at

    @KarimBel - 

     

    A few issues:

     

    1. I notice you have not included a GUID in your Patch. You will need to include the GUID in your Collection and in your Patch statement
    2. You do not need Defaults here. If the Patch formula identifies a GUID for each record in your collection, the matching record with that GUID is updated, if a GUID is not found, a new record is created.
    3. You do not necessarily need to precede Patch with a ForAll. It is more performant doing this the other way around

     

    Consider the below:

     

    Patch(
     ShoeOrdersTables,
     ForAll(
     colShoppingCart,
     {
     'The Logical Name of Your GUID column': colShoppingCart[@'The Logical Name of Your GUID column'],//GUID
     QTY: Value(TextInput2.Text),
     Name: txtName.Text,
     ProductName: Title4.Text,
     Address: txtAddress.Text,
     Comment: txtComment.Text,
     TotalPrice: With(
     {
     ST: Sum(
     colShoppingCart,
     Total
     )
     },
     ST + ST * 0.21 + 4.99
     )
     }
     )
    )

     

    Note: you can identify the logical name of your GUID column by navigating to the Columns view, and filtering on the Data Type of "Unique Identifier":

     

    Amik_0-1710622911220.png

  • KarimBel Profile Picture
    6 on at

    @Amik 

     

    Thanks for your response. For the GUID, so I have the column 'ShoeOrders' as GUID. The logical name of this column in dataverse is 'solestyl_shoeorderid'. Does it mean that the formula below must than be correct:

     

     

    Patch(
     ShoeOrdersTables,
     ForAll(
     colShoppingCart,
     {
     'solestyl_shoeordersid': colShoppingCart[@'solestyl_shoeordersid'],//GUID
     QTY: Value(txtQTY.Text),
     Name: txtName.Text,
     ProductName: lblProductname.Text,
     Address: txtAddress.Text,
     Comment: txtComment.Text,
     TotalPrice: With(
     {
     ST: Sum(
     colShoppingCart,
     Total
     )
     },
     ST + ST * 0.21 + 4.99
     )
     }
     )
    )

     

     

    Because I get an error that the name isn't valid and that the function Patch has some invalid arguments:

    KarimBel_0-1710752581872.png

     

    Karim

  • Ami K Profile Picture
    15,674 Super User 2024 Season 1 on at

    @KarimBel -

     

    Please could you take a screenshot of the error message (hover over the red line and then take a screenshot).

     

    Have you included the GUID in your collection?

  • KarimBel Profile Picture
    6 on at

    Hi @Amik 

     

    This is my formula for the collection and as you can see I didn't include the GUID:

     

    Collect(colShoppingCart, {Title:ThisItem.ProductName, Productprice:ThisItem.ListPrice, ProductID:ThisItem.ProductNumber, QTY:Slider2.Value, Total: (Slider2.Value * ThisItem.ListPrice)});Set(varShowSucces,true)
     
    What do I need to do?
     
    Thanks

    Karim
     
    Thanks
     
    Grtz
  • Verified answer
    Ami K Profile Picture
    15,674 Super User 2024 Season 1 on at

    @KarimBel - as stated in my first response to your post - include the GUID in the Collection.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard