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 / Patching a nested gallery
Power Apps
Unanswered

Patching a nested gallery

(0) ShareShare
ReportReport
Posted on by 25

Hello,

 

I'm in need of help to patch data into a SharePoint list from a nested gallery. My screen structure involves a dropdown menu that the user selects an option from (within the Parent gallery), and for each option there are multiple records that need to be answered (within the Child gallery). 

 

I've tried writing a nested ForAll within the formula to patch the data when the user saves the answers. However, this is not working and I'm not sure how to fix it.

 

(Something to note is that I've added a hidden label (Label_TopProp) within the Child gallery that references the Parent gallery dropdown menu value, to try and store that selected option with one patch statement.)

 

Any help would be appreciated. Cheers!

powerapps_gallery.PNG
powerapps_screen.PNG
powerapps_formula.PNG
Categories:
I have the same question (0)
  • Ramole Profile Picture
    Super User 2024 Season 1 on at

    @pen253 
    To use ForAll() see below.

    ForAll(Gallery_Child.AllItems, Patch(
    
     Answers_S4_C1_Processing,
    
     {
     Title: User().FullName & "-" & Now()
     }
    
     )
    
    )

     Also have look this post Patch a record into Share point with a nested Gallery 

  • WarrenBelz Profile Picture
    155,487 Most Valuable Professional on at

    Hi @pen253 ,

    Firstly please post all code as Text - makes it far easier to correct - try this

    ForAll(
     Galllery_Parent.AllItems,
     ForAll(
     Gallery_Child.AllItems As aPatch,
     Patch(
     Answers_S4_C1Processing,
     Defaults(Answers_S4_C1Processing),
     {
     Title: User().FullName & "-" & Now(),
     UserID: gblUser.ID,
     Top_Prop: aPatch.LabelTopProp.Text,
     . . . . . 
     }
     )
     )
    )
     

    and replace ThisRecord with aPatch on the rest.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • pen253 Profile Picture
    25 on at

    Hi @WarrenBelz,

     

    Thanks for your help! The updated code is below. The button can now be selected without any errors and navigate to the next screen - but the data isn't being stored in the SharePoint list. Any idea why this could be the case?

     

    ForAll(
     Gallery_Parent.AllItems,
     ForAll(
     Gallery_Child.AllItems As aPatch,
     Patch(
     Answers_S4_C1_Processing,
     Defaults(Answers_S4_C1_Processing),
     {
     Title: User().FullName & "-" & Now(),
     UserID: gblUser.ID,
     QuestionID: aPatch.ID,
     Top_Prop: aPatch.Label_TopProp.Text,
     Condition: aPatch.Label_Conditions.Text,
     Value_min: aPatch.TextInput_Min,
     Value_max: aPatch.TextInput_Max,
     Relationship: aPatch.Dropdown_Relationship.SelectedText.Value
     }
     )
     )
    );
    
    Navigate(Quality_Calculation_C2, Fade);

     Cheers! 

  • WarrenBelz Profile Picture
    155,487 Most Valuable Professional on at

    Hi @pen253 ,

    Interesting - I must admit I have never tried to do exactly what you are doing, but it should work - maybe run a monitor session and see if the ForAll is being actioned

  • pen253 Profile Picture
    25 on at

    It appears to have run successfully, but still no data within the SharePoint list. I have been able to save data for other screens, so it isn't a fundamental connection issue between Power Apps and SharePoint.

    powerapps_monitor.PNG

    Cheers

  • WarrenBelz Profile Picture
    155,487 Most Valuable Professional on at

    HI @pen253 ,

    For a bit of debugging, try patching only the child gallery using the code I supplied from a button inside the main gallery and see if that works on just that parent record.

  • pen253 Profile Picture
    25 on at

    As you said, I used the following code for a button located within the Parent gallery. The error log is attached.

     

    ForAll(
     Gallery_Child.AllItems As aPatch,
     Patch(
     Answers_S4_C1_Processing,
     Defaults(Answers_S4_C1_Processing),
     {
     Title: User().FullName & "-" & Now(),
     UserID: gblUser.ID,
     QuestionID: aPatch.ID,
     Top_Prop: aPatch.Label_TopProp.Text,
     Condition: aPatch.Label_Conditions.Text,
     Value_min: aPatch.TextInput_Min,
     Value_max: aPatch.TextInput_Max,
     Relationship: aPatch.Dropdown_Relationship.SelectedText.Value
     }
     )
    );
    
    Navigate(Quality_Calculation_C2, Fade);

    Cheers

    powerapps_monitor2.PNG
  • WarrenBelz Profile Picture
    155,487 Most Valuable Professional on at

    Hi @pen253 ,

    I have built a model to test this (as I mentioned I had not done it before) - I actually got this working as a button in the parent gallery

    Patch(
     Answers_S4_C1_Processing,
     ForAll(
     Gallery_Child.AllItems As aPatch,
     {
     Title: User().FullName & "-" & Now(),
     UserID: gblUser.ID,
     QuestionID: aPatch.ID,
     Top_Prop: aPatch.Label_TopProp.Text,
     Condition: aPatch.Label_Conditions.Text,
     Value_min: aPatch.TextInput_Min,
     Value_max: aPatch.TextInput_Max,
     Relationship: aPatch.Dropdown_Relationship.SelectedText.Value
     }
     )
     )

    however,  the fundamental problem is that the child gallery itself is not actually recognised in the second ForAll. The actual "child" is the grouped table column data that forms the gallery Items (not the gallery itself), so you have to refer to the fields in that table, not the controls in the child gallery (I successfully patched using these), so somehow you are going to need to write to that table before patching.

     

  • pen253 Profile Picture
    25 on at

    Hi @WarrenBelz,

     

    Thank you very much for your help with this so far! It's interesting that your button within the parent gallery is working, because when I copy in your code I still get the error "Network error when using Patch function: The requested operation is invalid".

     

    On your other point, I'm not familiar with grouped table column data. Do you have any suggestions about how to write to that table before patching? Alternatively, is there any other way to set up the screen to simplify the patch?

     

    Cheers! 

  • WarrenBelz Profile Picture
    155,487 Most Valuable Professional on at

    Hi @pen253 ,

    As I mentioned, I used the actual Table column name (not the child gallery) in the Patch. I assume you are using GroupBy in the Parent Gallery and then the Child Gallery Items would be ThisItem.YourGroupedFieldName. If all this is true, you actually need to write back to the "parent" list on each item at the time you change the Child Gallery, so the whole subject of this thread is redundant as the data will already be there.

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 421

#2
Valantis Profile Picture

Valantis 405

#3
timl Profile Picture

timl 337 Super User 2026 Season 1

Last 30 days Overall leaderboard