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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch, Invalid argumen...
Power Apps
Answered

Patch, Invalid argument type

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to do a patch where you delete a selected item from a gallery and also from a datasource. And then update the column Total which is in a another table called PaymentVaucher. Tables are linked with LineItems.ItemID = PaymentVaucher.ID

BrowseGallery has a datasource of sql table LineItems, and form has a datasource of another sql table PaymentVaucher. Both are on one Screen.

 

The patch is happening on a delete button on OnSelect, in BrowseGallery2:

Screenshot_1111.png

You can see an error "Invalid argument type." How to fix this? Maybe my whole patch is wrong?

If I only use: Remove('[dbo].[LineItems]', BrowseGallery2.Selected) . Then the line gets removed from gallery and datasource, but ofcourse the update for Total in table PaymentVaucher does not happen.

 

 

Here is how the whole thing looks for better understanding:

Brez naslova.png

 

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @Anonymous ,

    Where is the invalid Argument type? I assume both values are numeric?

    Try this structure

    Patch(
     '[dbo].[PaymentVaucher]',
     {ID:BrowseGallery2.Selected.ItemID},
     {
     Total: 
     Sum(
     BrowseGallery2.AllItems,
     Value(Price)*Quantity
     ) - BrowseGallery2.Selected.Price
     }
    ); 
    RemoveIf(
     '[dbo].[LineItems]', 
     ItemID=BrowseGallery2.Selected.ItemID
    )
    

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz 

     

    Invalid argument type shows on a =, at the "BrowseGallery2.Selected.ItemID='[dbo]'[PaymentVaucher].ID". You can see it in the screenshot. Both ID from PaymentVaucher, and ItemID from BrowseGallery2 (datasource LineItems) are numeric.

     

    I tried your structure.

    I am getting error for AllItems. "Invalid argument type (Table). Expecting a Number value instead. The function 'Sum' has some invalid arguments."

     

    I can only add ThisItem.Price and ThisItem.Quantity in the sum.

    { Total: Sum( BrowseGallery2.AllItems,Value(ThisItem.Price),ThisItem.Quantity) - BrowseGallery2.Selected.Price }

     

     

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    @Anonymous ,

    The second part was simply copying your code - I had to OCR it (supplying in Text is always useful) and it had an operator wrong (now fixed).
    For the first bit, there is something clearly wrong here as two numeric values should not mismatch. I assume ItemID is contained in '[dbo].[LineItems]' . Have a look at both this field and also ID in '[dbo].[PaymentVaucher]' and ensure they are exactly the same field type.

    I did a test on this syntax with  a list and gallery and it worked fine except I am wondering if you need Value() around Price if it is already numeric.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

     

     

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz 

     

    Had to change it a bit. But the main problem was solved by your post. Thanks.

     

    Final structure:

     

    Patch(
     '[dbo].[PaymentVaucher]',
     {ID:BrowseGallery2.Selected.ItemID},
     {
     Total: Sum( BrowseGallery2.AllItems,Value(Price)*Quantity) - BrowseGallery2.Selected.Price
     }
    ); 
    Remove(
     '[dbo].[LineItems]',
     BrowseGallery2.Selected
    )

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard