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 / Updating all records i...
Power Apps
Answered

Updating all records in a gallery which is inside another gallery

(1) ShareShare
ReportReport
Posted on by 150

Looking through the existing answers I didn't see anything that directly addresses this, but so many get so close!  Hopefully this is possible.

 

What I'm trying to do is create a gallery of parts with records in the gallery showing a sub-gallery with dates which are associated with each part.

 

Example display:

AaronO_0-1639427772881.png

 

How can I get the buttons to work so that they properly check or uncheck all of the boxes in the sub-gallery?

I don't want to patch directly to the SharePoint data until the user clicks a save button (not created yet).  So that means I need to keep the gallery record data in-app until then.  Or if the only way to do it is direct patching to SharePoint, I'll just do that.

 

Thanks!

Categories:
  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Have you considered using a collection to do this. If you collect and patch to the collection the changes you can then use a save at the end to patch from the collection to the sharepoint site 🙂 ?

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

    HI @AaronO ,

    On the Reset of the Checkboxes

    varReset

    the Default

    varCheck

    The Mark All button

    UpdateContext(
     {
     varCheck: true,
     varReset: true
     }
    );
    UpdateContext({varReset: false})

    The Unmark All Button

    UpdateContext(
     {
     varCheck: false,
     varReset: true
     }
    );
    UpdateContext({varReset: false})

     

    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.

    Visit my blog Practical Power Apps

     

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Apologies i misread the question please se @WarrenBelz answer I am in agreement with their approach and it is likely your solution

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AaronO 

    Since you are doing this in a gallery, you are going to need to take note of the ID of the record it belongs to.  If you try to use a variable for it, then you will end up with everything in all records changing.

     

    So, you can do this with a common variable or a collection.  It would be easier to explain with a collection, although a collection is overkill.

     

    So, on the MarkAll button, set the OnSelect action to:

        Collect(colMark, {ID: ThisItem.ID})

    In the Unmark All, set the OnSelect to:

        RemoveIf(colMark, ID=ThisItem.ID)

     

    You will need to pass the ID to the sub gallery in the Items property.

    This can easily be done with:  AddColumns(yourExistingSubGalleryItemsProperty, "parentID", ThisItem.ID)

     

    Then on the CheckBoxes in your sub gallery, set the Default property to:

        LookUp(colMarks, ID=ThisItem.ParentID, true)

     

    Then, set your Reset property on the Checkbox to : yourUnMarkButton.Pressed || yourMarkButton.Pressed

     

    This will give you control record by record in your gallery.

     

    I hope this is helpful for you.

     

  • AaronO Profile Picture
    150 on at

    Thank you for the reply.  I tried this, and found that it checks the boxes for parts outside the current record where I click the button.  I would need the button to only update the current part.

     

    Also, how would this play with the data source since I had to overwrite my default value which was pulling from a SharePoint list?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AaronO 

    The formulas I provided for you account for that issue.  Give it a try.

  • AaronO Profile Picture
    150 on at

    @RandyHayes 

    Your solution works even better than I expected.  Exceptional!

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AaronO 

    Very good!  Yes, trying to use just a variable on a Gallery to control row level items causes issues because it really needs to account for the actual row, not the whole gallery.

    Now, if your mark/unmark buttons were outside of the gallery and intended to mark or unmark all records, then a standard variable would suffice.

  • AaronO Profile Picture
    150 on at

    @RandyHayes 

    Can you explain to me how this works with the collection? 

    Once I press the mark button for one part, why doesn't that leave the ID in the collection, then when I press the button again it resets all parts which have been added to the collection? 

    I did notice that I can make changes to the gallery checkboxes after using the mark button, and I can then mark other parts, but this doesn't affect the other parts in the collection.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AaronO 

    The collection is just an in-memory database of ID's that are selected to be marked.

    When you press the mark button, it will put a row in the collection with that record ID in it.

    When you press the unmark button, it will remove the row(s) with that ID in it.

    That is the only purpose of the collection...just to keep track of "marked" records.

     

    The rest of the magic comes from the Default and the Reset of the checkbox control.  The Default will do a lookup on the collection, if it finds that parent ID in it, the lookup will return true and thus the checkbox will be checked.

    The Reset provides the ability to reset checkboxes that have been manually set.  Once you manually set a checkbox, the default will no longer play in the game.  So, the Reset property will reset the control (when either button is pressed) which will set it to what was selected (again, based on the Lookup).

     

    Hopefully that answers your question on it.  If not, let me know where to expand.

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 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard