web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details
Power Apps - Building Power Apps
Answered

Save info from nested gallery to a collection

Like (0) ShareShare
ReportReport
Posted on 13 Oct 2022 12:17:30 by 39

Hello,

 

 I am having trouble grabbing the data from a nested gallery and saving it to a collection.

 

I have a vertical gallery (Gallery1) and nested inside Gallery1 is a horizontal gallery (Gallery2). The data source for Gallery1 is a Sharepoint list and the datasource for Gallery2 is the attachments list for each item in Gallery1. Each item in Gallery1 can have any number of attachments.

 

Gallery2 displays the image and it's display name. I want to be able to save the all the images and display names for each attachments list for each item displayed in Gallery1.

 

I have a button when selected is supposed to collect the data and save it to a collection. The following is the code.

 

Clear(imageCollection);
Collect(imageCollection,
 ForAll(Gallery1.AllItems,
 {
 DataStream: Image.Image,
 Name: fileName.Text
 }
 )
);

 

 

Which gives me the following Collection:

Dmwolny_1-1665663196177.png

 

I have tried a number of different formulas with no success.  Please steer me in the right direction

 

 

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 13 Oct 2022 at 14:45:15
    Re: Save info from nested gallery to a collection

    @Dmwolny 

    Your gallery already contains all of your data!!  Putting it in a collection is just duplicating the data you already have.

     

    But if there is some particular reason to duplicate it, then please consider changing your Formula to the following:

    ClearCollect(imageCollection,
     Ungroup(
     ForAll(Gallery1.AllItems,
     ForAll(Gallery2.AllItems,
     {DataStream: Image.Image,
     Name: fileName.Text
     }
     )
     ),
     "Value"
     )
    );

     

    There is one caveat to this...nested galleries (Gallery2) do not naturally give up their AllItems tables.  You need to force the primary gallery to invoke data from the nested gallery.  To do this, place a label in your parent gallery and set the Text property to: CountRows(Gallery2.AllItems)  

    You can make the label hidden...it just needs to exist to "invoke" the reveal of the gallery.  That formula does not have to be based on AllItems, it can reference anything in the gallery, but I find the above simple enough.

     

    I hope this is helpful for you.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2