cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Accessing a Nested gallery allitems.

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?

 

 

  

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Hi @Pen ,

 

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:})


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

3 REPLIES 3
Highlighted
Community Support
Community Support

Hi @Pen ,

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/t...

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

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
    )
);

 

 

Highlighted

Hi @Pen ,

 

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:})


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Proud to be a Super User!

Regards,
KrishnaV
Business Applications MVP
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,531)