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 / Patch each row in a ga...
Power Apps
Unanswered

Patch each row in a gallery to a table?

(0) ShareShare
ReportReport
Posted on by 34

and49_0-1660230196219.png

I have the above in an app. The idea is that the user fills in the dropdown/text box/image field and is able to click "Next" button which will save each item in the gallery with the new data to a new row in dataverse. (Ignore the "Save Record" check box)

 

After many iterations of a "ForAll" function I'm failing to get to my desired point. 
Currently I have this formula:

and49_1-1660230345787.png

Which for whatever reason inserts four identical rows based off the user's input in the first item in the gallery. This seems strange to me as there are 9 items in the gallery so i would expect to see 9 rows created. 

The two problems are as follows:

1. My formula only looks at the first item in the gallery's data. 

2. my formula only creates 4 new rows in dataverse when the ForAll loop should be bringing back 9 (one for each of the items in the gallery)

 

Any help would be greatly appreciated on this as it's driving me insane! 
Thanks so much

 

 

 

Categories:
I have the same question (0)
  • BCBuizer Profile Picture
    22,510 Super User 2025 Season 2 on at

    Hi @and49 ,

     

    The BaseRecord selection seems to be missing in your Patch statement:

     

    PatchDataSourceBaseRecordChangeRecord1 [, ChangeRecord2, … ])

     

    https://docs.microsoft.com/en-us/power-platform/power-fx/reference/function-patch#modify-or-create-a-record-in-a-data-source-1

     

    In case you want to only create new records, try:

     

     

    Patch('Audit Answers', Defaults('Audit Answers'),{....

     

  • and49 Profile Picture
    34 on at

    I have added the default, the result is still the same. Four records are created with all fields matching the data entered in the last field.

    and49_0-1660232642961.png

    Creates:

    and49_1-1660232656678.png

    Edit: Just to confirm I only want to add new records to the table.

  • BCBuizer Profile Picture
    22,510 Super User 2025 Season 2 on at

    Hi @and49 ,

     

    Can you please  share the full code together with the result? That makes it a lot easier to find the issue.

  • and49 Profile Picture
    34 on at

    I'm not sure what else to send, the code is there and the result from the table. Is there anything specific you want?

  • BCBuizer Profile Picture
    22,510 Super User 2025 Season 2 on at

    Hi @and49 ,

     

    The code is in the opening post, but I assume you have made changes to that after my feedback. Can you please send the latest code you are using?

  • and49 Profile Picture
    34 on at

    and49_0-1660292590542.png


    It's exactly the same with the Defaults added in, the result is identical to the result before. 
    The table is populated with four rows with values matching those of the last "filled-in" item in the gallery with data. 

  • BCBuizer Profile Picture
    22,510 Super User 2025 Season 2 on at

    Hi @and49 ,

     

    The code in itself should be working, so can you please check the references to see if they are towards the correct controls?

  • Yozgart Profile Picture
    18 on at

    I know it's late (months later), but I found a solution for a similar issue. I just added the statement ThisRecord. instead of the actual gallery mapping. 

     

     

    ForAll(
     VendorPricesGallery.AllItems,
     Patch(
     tblItemMasterVendor,
     Defaults(tblItemMasterVendor),
     {
     idItemMaster: _idItemMaster,
     dPurchaseCost: ThisRecord.dPurchaseCost,
     vVendorID: ThisRecord.VendorId.vVendorID,
     idCatItemMasterCurrency: Value(
     LookUp(
     tblCatCurrencies,
     idCatItemCurrency = ThisRecord.idCatItemCurrency
     ).idCatItemCurrency
     ),
     dCreatedDate: ProposalGallery.Selected.dUpdatedDate,
     vCreatedUser: ProposalGallery.Selected.vUpdatedUser.'User Name'
     }
     )
    )

     

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard