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 / Accessing a Nested gal...
Power Apps
Answered

Accessing a Nested gallery allitems.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to create a collection from a subgallery, I can create a collection from the gallery using

ForAll(
 Gallery.AllItems,
 Collect(
 GalleryCollection,
 ThisRecord
 )
);

This is great, however, I can see the nested gallery in my new collection however the AllItems are not included, just the gallery control.

 

I have been trying:

ForAll(
 Gallery.AllItems,
 ForAll(
 Subgallery.AllItems,
 Collect(
 SubGalleryCollection,
 ThisRecord
 )
 )
);

To no avail, the collection columns are created but nothing is stored in the SubGalleryCollection.

 

Any idea how I can reference the SubGallery items for each of the gallery items?

 

 

  

Categories:
  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Could you tell me

    1)the data structure of the gallery.AllItems?

    2)what data do you want from gallery.AllItems? which columns? which control data?

    If you could describe with screen shoot , it will be better to understand.

    To get data from nested table, we usually use formula like this:

    For example: in collection1, to get column field1's data(nested table)

    Clear(collection2);
    ForAll(collection1,
     Collect(collection2,
     field1
     )
    )

    Here's a issue about getting data from nested table for your reference:

    https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/How-to-access-nested-table-values/td-p/313821

     

     

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Phoebe 

    Thanks for the response.

    So this diagram kind of explains (I hope) what I am trying to do:

     
     
     

    savesection.png

    I can save the individual items in Gallery1 with the following formula, its quite complex due to the nature of the CDS.

     

    Switch(
     ThisItem.'Question Type',
     'Question Type'.'Large Text',
     Patch(
     Collection1,
     Gallery1.Selected,
     {'Master Text Response': responseLargeText.Text},
     {Answered: true}
     ),
     'Question Type'.Number,
     Patch(
     Collection1,
     Gallery1.Selected,
     {'Master Numerical Response': Value(responseNumber.Text)},
     {Answered: true}
     ),
     'Question Type'.Optionset,
     Patch(
     Collection1,
     Gallery1.Selected,
     {Answered: true}
     
     );
     ClearCollect(
     optionsTempCol,
     responseOptionSet.Selected
     );
     ClearCollect(
     tempOptionsCol,
     Filter(
     Collection2,
     'Question (Response)'.'Ref Number' = ThisItem.'Ref Number',
     Type = 'Type (Question Options)'.'Question Option'
     )
     );
     ForAll(
     tempOptionsCol,
     UpdateIf(
     Collection2,
     'Question Option' in tempOptionsCol.'Question Option',
     {'Is Selected': false}
     )
     );
     If(
     CountRows(optionsTempCol) > 0,
     ForAll(
     optionsTempCol,
     UpdateIf(
     Collection2,
     'Question Option' in optionsTempCol.'Question Option',
     {'Is Selected': true}
     )
     )
     );
     ,
     'Question Type'.'Multi-Select Optionset',
     ForAll(
     Gallery2.AllItems,
     UpdateIf(
     Collection2,
     'Question Option' = GUID(hidRefNumber2.Text),
     {'Is Selected': multiSelectCheck.Value}
     )
     );
     Patch(
     Collection1,
     Gallery1.Selected,
     {Answered: true}
     );
     
    );
    If(
     CountRows(Gallery3.AllItems) > 0,
     ForAll(
     Gallery3.AllItems,
     UpdateIf(
     Collection2,
     'Question Option' = GUID(hidRefNumber.Text),
     {'Is Selected': promptCheck.Value}
     )
     )
    );
    Concurrent(
     Patch(
     Questions,
     Collection1
     ),
     Patch(
     'Question Options',
     Collection2
     );
     
    );

     

    This works great, I have to do the patch at the end as the galleries don't update from the collections.

     

    So I am trying to do the above for ALL items in Gallery1. 

     

    So when I collect Collection1, the gallery AllItems are blank.

    savesection2.png

    ThisRecord returns the control, but not the items....

    Still can't get any of the Gallery2/3 items into the collection but it does work for a Listbox.SelectedItems

     

     

    /* this Doesnt Work */
    ForAll(
     Gallery1.AllItems,
     Collect(
     Collection2,
     resMultiSelectGallery.AllItems
     )
    );
    /* this Works */
    ForAll(
     Gallery1.AllItems,
     Collect(
     Collection2,
     Listbox.SelectedItems
     )
    );

     

     

  • Verified answer
    KrishnaV Profile Picture
    5,023 on at

    Hi @Anonymous ,

     

    Please implement this as below:

    Create a collection with key value pain while you are building the gallery 
    ClearCollect(collQuestions,{qstnID:1,qst:"",Value:""})

    The collection will be as follows:

    1,question1,""
    2,question2,""
    3,question3,""
    4,question4,""
    On submit / Save click read through this collection and save it back to datasource:

    Patch(collQuestions,qstnID=Lookup(collQuestions,qstnID=thisItem.ID,qstnID),{Value:})

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
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard