Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
Answered

Patch all items in a grid or subgrid - new power Fx Commanding

(0) ShareShare
ReportReport
Posted on by

Hi Community, 

 

Has anyone figured out how to patch multiple selected items in a grid / sub grid using the new Power Fx commanding for Model-Driven apps? 

 

Following this guide, I'm able to patch a single selected contact record in a subgrid (subgrid is on the account form). However, selecting multiple records does not execute the patch function. I've tried wrapping the patch in a for all using self.selected.allitems however that didn't work. 

 

This is the selected record patch statement, works fine for a single record. 

 

Patch(Contacts,
Self.Selected.Item,
{
'Mobile Phone': 123456,
'Last Name': "Doe"
})

 

 

I realise this is still in preview, however seeing if folks have figured this out? 

Categories:
  • user45 Profile Picture
    5 on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    It's the same for me, and there is not any information anywhere searched within some 3-4 hours - just for this formula, - to patch for all selected records. Which is totally absurd. 

  • user45 Profile Picture
    5 on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    Are you a criminal? Considering that this is incorrect and the formula works without any "single quotes", but it does not work at all given that it adds new records and does not patch, so you are all trolls and criminals. And there is not another version which works to patch the records. And if there is it is totally illogical in some way or other. And the spamming below is about the same, and you could be a bunch of criminals who hack into computers and mess with people's lives to the most horrendous and criminal extent.

  • Dpop Profile Picture
    13 on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    this could be just from your copy and paste but your Datasource needs to be wraped in single quotes.. Also generally ur going to need to include the primary column as well as that is usually a required field... you also have semi colons where they should just be commas.. this seems to be all syntax related....

     

    here how I believe it should be formatted: 

    Patch('DataSource',ForAll(Self.Selected.AllItems,{'Data Field1':ThisRecord.'DataField'DataField2: 'Data Field2 Value'}))
     
    You wont need the single since you dont have spaces in your datasource or fieldnames.. but you need to have commas instead of semicolons for sure
  • Pokke Profile Picture
    58 on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    i tried to patch multiple records with running the command bar with Powerfx Patch command. 
    But i running in the issue that items where created and not updated or nothing is happen. 

    My formula i using is the following:

    Patch(
        PMO_Projektliste;
        ForAll(Self.Selected.AllItems;
           {
            Statusbericht_requested:Today()
            }
        )
    )


    My Table name is PMO_Projektliste and the column Statusbericht_requested is a date column. But i already tried a string column, its always the same. 

    When i type in more than one update in the patch formula like this:

    Patch(
        PMO_Projektliste;
        ForAll(Self.Selected.AllItems;
           {
            Projektbezeichnung:ThisRecord.Projektbezeichnung;
            Statusbericht_requested:Today()
            }
        )
    )
    It creats a record. 

    With the first code there happens nothing.... Patch only one item is working. Maybe someone can help me.
  • Dpop Profile Picture
    13 on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    @ScottDurow Im running into a bug maybe when I use the mentioned logic.. My primary key is empty so it actually seemingly creates new records instead of updating.. I tried using the recordID guid field and that seemed to update the records but then all the records now have the same guid

     Any thoughts?

     

    --Update: Actually is working as expected!!! Thanks Again

  • Jdiekman101 Profile Picture
    on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    Awesome @ScottDurow didn't even think to look at ThisRecord 😁

  • Verified answer
    ScottDurow Profile Picture
    1,039 on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    I’ve updated the post with how to do this!

    https://develop1.net/public/post/2021/07/25/RibbonWorkbench-vs-PowerFx

  • Jdiekman101 Profile Picture
    on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    Thanks, @ChrisPiasecki - just took a look. Seems like JS is the only way at the moment which is ok. Thanks for the info 🙂 

  • Verified answer
    ChrisPiasecki Profile Picture
    6,389 Most Valuable Professional on at
    Re: Patch all items in a grid or subgrid - new power Fx Commanding

    Hi @Jdiekman101,

     

    I don't believe running a command on multiple selected rows is available yet (hopefully soon though!). 

     

    @ScottDurow just published a nice writeup comparing the classic Ribbon Workbench to what is currently possible in the new Power FX Command Designer.

     

    https://develop1.net/public/post/2021/07/25/RibbonWorkbench-vs-PowerFx

     

    ---
    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Microsoft Dataverse

#1
stampcoin Profile Picture

stampcoin 17

#2
mmbr1606 Profile Picture

mmbr1606 15 Super User 2025 Season 1

#3
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

Overall leaderboard

Featured topics