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 / Save info from nested ...
Power Apps
Unanswered

Save info from nested gallery to a collection

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @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.

  • Dmwolny Profile Picture
    39 on at

    Thank you Randy, that did the trick.

     

    Ultimately I want to send out an email with the all the data from Gallery1 including all of the attachments. I have a Flow that accepts a JSON and then compiles the JSON into an email. I wasn't sure how to nest the attachments into a Collection to send out as a JSON.

     

    I wanted to split the data into 2 collections, 1 with strings and second with the image data. Perhaps there is a more elegant way to accomplish this.

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

    @Dmwolny 

    Well, the main point of my response was that your gallery has the data.  So duplicating into a collection is just that..a duplication.

     

    In other words:

    ClearCollect(someCollection, <theFormulaIprovided>);
    someFlow.Run(JSON(someCollection))

    This would be duplicating the data to then convert to JSON.

     

    Whereas:

    someFlow.Run(JSON(<theFormulaIprovided>))

    Is equivalent and does not duplicate unnecessarily.

     

  • Dmwolny Profile Picture
    39 on at

    Thanks, you gave me something to chew on

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard