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 all gallery item...
Power Apps
Answered

Patch all gallery items to Dataverse Table

(0) ShareShare
ReportReport
Posted on by 293

My app has two screens.

 

Screen one is a gallery of orders (Dataverse Table).

 

Selecting a record takes you to screen two, a gallery of order lines (second Dataverse Table).

 

A quantity field in the gallery is an editable input.

 

At the top I have a submit button to submit all changes back to the table.

 

Below is the code for my submit button. I constantly get an 'Invalid argument type' error and I can't for the life of me figure out why.

 

Any ideas?

 

 

ForAll(
 gal_OrderLines.AllItems,
 Patch(
 'POReader-OrderLines',
 LookUp(
 'POReader-OrderLines',
 ID=ThisRecord.ID &&
 LineID=ThisRecord.LineID
 ),
 {Qty:inp_Qty.Text}
 )
);

 

Categories:
I have the same question (0)
  • Bilakanti Profile Picture
    1,226 on at

    @AlexMCC - Can you try renaming the GalleryOrderline items and try once, and what is Qty column type, if its number then convert it into Value.

     

    ForAll(
     gal_OrderLines.AllItems As galLineItems,
     Patch(
     'POReader-OrderLines',
     LookUp(
     'POReader-OrderLines',
     ID=galLineItems.ID &&
     LineID=galLineItems.LineID
     ),
     {Qty:inp_Qty.Text}
     )
    );

     

  • AlexMCC Profile Picture
    293 on at

    Thanks for the suggestion @Bilakanti , unfortunately it made no difference. 😞

  • Bilakanti Profile Picture
    1,226 on at

    @AlexMCC - can you try to pass a static value in {Qty:"2"} and see if you still run into the same issue.

  • AlexMCC Profile Picture
    293 on at

    Thanks again @Bilakanti , but still no luck.

     

    I tried a few things.

     

    First, I transferred my button to the gallery to patch only a single item, using the following syntax, which works fine:

    Patch(
     'POReader-OrderLines',
     LookUp(
     'POReader-OrderLines',
     ID=ThisItem.ID &&
     LineID=ThisItem.LineID
     ),
     {Qty:Int(inp_Qty)}
    )

     

    As soon as I put my code within a ForAll loop, whether I use static or dynamic values, I get an invalid argument error.

     

    I've looked at the solution here , but it doesn't seem to help in my case.

     

    I've also tried using a collection.

     

    Curiously, I've found that my table does not turn teal in the code editor, as it does when Power Automate recognises it as a valid table.

     

    Here are screenshots using a different table as patch destination. Maybe just a visual bug, but also maybe an indication that something is off.

     

    Screenshot 2023-01-30 at 07.01.39.png

    Screenshot 2023-01-30 at 07.02.01.png

  • AlexTheKidd Profile Picture
    178 on at

    Here's the code I use to patch all gallery items - this always works for me:

     

    ForAll(
     RenameColumns(
     gal_OrderLines.AllItems,
     "ID",
     "IDD"
     ),
     Patch(
     'POReader-OrderLines',
     LookUp(
     'POReader-OrderLines',
     ID = IDD
     ),
     {QTY:inp_Qty.Text}
     )
    )

     

     

  • AlexMCC Profile Picture
    293 on at

    Thanks @AlexTheKidd for the thorough suggestion.

     

    I just did some more testing and it's definitely the data source that's acting up. If I try to patch a different Dataverse table, I don't have any issues.

     

    What could be causing this?

     

    It must be some setting in my Dataverse table.

  • AlexTheKidd Profile Picture
    178 on at

    Hi @AlexMCC ,

     

    Could it be that the column in Dataverse is not called "QTY"? I've had the same experience previously.

    A test you could do is to create a button that only patches a single text/value to the QTY column, just to be sure that you can patch to the column. 

     

    If you add the code I posted, and hover over the text with the red squiggly lines, what does the text say? Screenshot would be beneficial.

  • AlexMCC Profile Picture
    293 on at

    Unfortunately, that's not it either. As you see from my reply above, I can get the patch to work fine, if I do one item at a time from within the gallery.

     

    So column names are not the issue.

     

    As soon as I type the table name within the ForAll loop, the function stops working.

     

    I'm starting to wonder if I've botched something with the table creation, since I have several lines with the same ID. It might be that I'm hitting an issue due to the duplicate detection rules.

  • Verified answer
    AlexMCC Profile Picture
    293 on at

    Alright, so this gave me some hints:

    Solved: Invalid argument type (GUID). Expecting a table va... - Power Platform Community (microsoft.com)

     

    I tried what was suggested and put my datasource in [@...] brackets and it worked!

     

    Somewhat, at least.

     

    It appears that either some of my column names or the table name itself is somehow conflicting.

     

    So I created a completely new table and it seems to have done the trick.

     

    Thanks so much for all the feedback on this!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 431

#2
WarrenBelz Profile Picture

WarrenBelz 360 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 280 Super User 2026 Season 1

Last 30 days Overall leaderboard