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 / how do i save all sele...
Power Apps
Unanswered

how do i save all selected gallery items in bulk

(0) ShareShare
ReportReport
Posted on by 45

I have 3 CDS tables: Disbursement Request  (1:N) Disbursement Selection (N:1)  Expenditures

The Disbursement Selection table should capture the Request ID and all records selected from the Expenditures.

The Gallery is a filtered (based on above drop downs) list of expenditures. Now I'd like to save all items of this gallery, rather than click save for each of the 100 rows.  

I am new to Collections and Patch. There should be no 'update' to the Expenditure table. Each Expenditure ID should be captured in the joining Disbursement Selection table, for each Request. 

Is there a method to create each row as a record in this joining table?

disbur.JPG

 

 

Categories:
  • eka24 Profile Picture
    20,925 on at

    Try

    ForAll(Gallery1.AllItems, Patch( YourList,Defaults(YourList),
    {YourListColumn1: Textbox1.Text}, {YourListColumn2: Textbox2.Text}, {YourListColumn3: Textbox3.Text}))

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@steph_io,

    Based on the issue you mentioned, you want to bulk save all your gallery selected items to the joining Disbursement Selection table in CDS

    Considering your request, some nested formula can achieve your needs.

    • Add a button, set the OnSelect property like this:            
     Collect(NewCollection,ShowColumns(Gallery1.AllItems,”ColumnName1”,”ColumnName2”,…..))
    • Set your Save button OnSelect property like this:
    ForAll(
     NewCollection,
     Patch(
     'Disbursement Selection',
     Defaults('Disbursement Selection'),
     {
     TableColumn1: CollectionColumn1,
     TableColumn2: CollectionColumn2,
     TableColumn3: CollectionColumn3,
     ... 
     }
     )
    )

    Note: Please make sure that the ColumnNames are an exact match to the columns in your joining table.

     

    Best Regards,

    Qi Qiao

  • steph_io Profile Picture
    45 on at

    So my Collection is working properly: 

    Collect(DisburseSelections, ShowColumns(Filter(GalleryExpenditures.AllItems, Checkbox3.Value = true), "Disbursement Request Selection Name", "Disbursement Request Selection Type", "CogsdaleExpenditure Lookup", "Disbursement Request Lookup","Disbursement Request Amount" ))

    The fields from the gallery are stored in the collection. 

     

    But the Patch does not: 

    ForAll(DisburseSelections,Patch('Disbursement Request Selections',Defaults('Disbursement Request Selections'), {'Disbursement Request Selection Name': 'Disbursement Request Selection Name', 'Disbursement Request Selection Type': 'Disbursement Request Selection Type', 'Disbursement Request Lookup': 'Disbursement Request Lookup', 'CogsdaleExpenditure Lookup': 'CogsdaleExpenditure Lookup','Disbursement Request Amount': 'Disbursement Request Amount'}))

     

    The error is : Value must be data entity record.

     

    I do have 2 CDS lookup fields. This joining 'Selection' table is to capture the reference to the Request and the Expenditure.

    In the Gallery these fields are storing the ID.  

     

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi@steph_io,

     

    I have seen the formula you provided, I understand you want to create a joining table named 'Disbursement Request Selections’ which actually is not an existing entity.

     

    The error shows that you need to refer to your existing entity record, which means the green part should be ‘Disbursement Selection’.

     

    What’s more, the blue part should be the columns in the table ‘Disbursement Selection’.

     

    ForAll(DisburseSelections,Patch('Disbursement Request Selections',Defaults('Disbursement Request Selections'), {'Disbursement Request Selection Name': 'Disbursement Request Selection Name', 'Disbursement Request Selection Type': 'Disbursement Request Selection Type', 'Disbursement Request Lookup': 'Disbursement Request Lookup', 'CogsdaleExpenditure Lookup': 'CogsdaleExpenditure Lookup','Disbursement Request Amount': 'Disbursement Request Amount'}))

     

    Here is the reference about Patch function:https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

     

    Best Regards,

    Qi Qiao

  • steph_io Profile Picture
    45 on at

    DisburseSelections is my collection.

    'Disbursement Request Selections' is my CDS joining table. Sorry I had renamed it in my tests. But yes it is the target entity name to create these records in.  The blue are my column names. (They are the same as the collection column names). 

     

    select.JPG

     

    There's no syntax error. I get the error at runtime.

     

  • steph_io Profile Picture
    45 on at

    ForAll(DisburseSelections,Patch('Disbursement Request Selections',Defaults('Disbursement Request Selections'), {cr6a2_disbursementrequestselectionname: 'Disbursement Request Selection Name', cr6a2_disbursementrequestselectiontype: 'Disbursement Request Selection Type', cr6a2_disbursementrequestlookup: 'Disbursement Request Lookup', cr6a2_cogsdaleexpenditurelookup: 'CogsdaleExpenditure Lookup', cr6a2_disbursementrequestamount: 'Disbursement Request Amount'}))

     

    This does not work either. 

  • steph_io Profile Picture
    45 on at

    ForAll(DisburseSelections,Patch('Disbursement Request Selections',Defaults('Disbursement Request Selections'), {cr6a2_disbursementrequestselectionname: 'Disbursement Request Selection Name'.Text, cr6a2_disbursementrequestselectiontype: 'Disbursement Request Selection Type'.Text, cr6a2_disbursementrequestlookup: 'Disbursement Request Lookup', cr6a2_cogsdaleexpenditurelookup: 'CogsdaleExpenditure Lookup', cr6a2_disbursementrequestamount: Value('Disbursement Request Amount'.Text)}))

     

    So this is now creating multiple records, but the 2 lookup fields are empty. 

     

  • steph_io Profile Picture
    45 on at

    This is my Collection: 

    Collect(DisburseSelections, ShowColumns(Filter(GalleryExpenditures.AllItems, Checkbox3.Value = true), "Disbursement Request Selection Name", "Disbursement Request Selection Type", "Disbursement Request Amount" , "CogsdaleExpenditure Lookup") )

     

    This is my Patch to save new records:

    ForAll(DisburseSelections, Patch('Disbursement Request Selections', Defaults('Disbursement Request Selections'), {cr6a2_disbursementrequestselectionname: 'Disbursement Request Selection Name'.Text, cr6a2_disbursementrequestselectiontype: 'Disbursement Request Selection Type'.Text, 'Disbursement Request Lookup': ComboBoxRequestLookup.Selected, 'CogsdaleExpenditure Lookup': GalleryExpenditures.Selected, cr6a2_disbursementrequestamount: Value('Disbursement Request Amount'.Text)}))

     

    The Disbursement lookup is now working.  I had to put the Lookup in a combo box to make it work. Even tho it should just save the 1 item (1 to many). 

    When I did the same with the Expenditure, it did not work. It is now just saving the last selected record of the Expenditures in the Gallery, and applies that last record to all saved Disbursement Request Selection records. 

     

    It's been 2 weeks and I am no where near launching this app. This should not be this difficult. It's been trial and error to test and retest to find a solution. 

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard