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 / Patch in SharePoint Li...
Power Apps
Unanswered

Patch in SharePoint List from Nested Galleries

(0) ShareShare
ReportReport
Posted on by 229

Hi, I'm having some problems with a ForAll and Galleries/subgalleries patch and I was wondering if someone can give me a hint. 

 

I have a collection/table with name of schools (column [school]) and users for those schools (column [name]).

 

  • I'm displaying in a Parent_Gallery the name of the schools using GroupBy. The Items property is  = GroupBy(colSchool,"school","grpSchool").
  • Then I have a Child Gallery to display the names of the users 
  • Finally I have a dropdown where the user can interact and select a value "Yes" or "No"

The view is something like this:

 Gallery.JPG

 

Once the user has selected Yes or No, They click on "Save" and the result should be stored in a SharePoint List as follow:

 

Table.JPG

 

The formula I am using in the OnSelect property for the button is

 

ForAll(galParent.AllItems,
 ForAll(galChild.AllItems,
 Patch(TEst_School,Defaults(TEst_School),{
 School:Label8.Text
 Name_ID:name,
 Value:Dropdown2.Selected.Value
 })
 )
) 

 

However, It is not doing anything. And I'm not getting any error/warning.

 

Any idea where is the problem?

 

Kind Regards

Categories:
  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @Sam4 ,

    A couple of things I have noticed here - name and Value are very bad field names as they are reserved words - you should consider changing them.

    This aside, I assume School is a field in the Child gallery (or you could not match it to the parent), therefore the nested ForAll should not be necessary when writing new records back to a list. You also need to add the drop-down value to the data as below with AddColumns.

    ForAll(
     AddColumns(
     galChild.AllItems,
     "Chosen",
     Dropdown2.Selected.Value
     ),
     Patch(
     TEst_School,
     Defaults(TEst_School),
     {
     School:School
     Name_ID:name,
     Value:Chosen
     }
     )
     )
    ) 

     

    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.

     

  • Sam4 Profile Picture
    229 on at

    Hi @WarrenBelz Thanks for you reply,

     

    I couldn't make it works, I guess it is the way I'm doing subgallery. I have only 1 table  that I'm using to populate the Parent and the Child galleries. I'm using GroupBy for Parent and Child gallery as this example PowerApps: Gallery / SubGallery using GroupBy and Flexible Height.  So School is not  in the subgallery. 

     

     

    so 1st) step in my process is format this table

     

    School Name

    School 1John
    School 1Jack
    School 1Jill
    School 2Chris
    School 2Clint

     

    to display as a gallery like this (Here it is where I'm using the GroupBy functiponality)

     

    table3.JPG

     

     

    2nd step in my process is to add a dropdown to select "Yes" or "No" next to the name.  and Patch the result in the database. This will be done on a daily basis so the database will be something like that: 

     

    ID Day School Name Comment

    1MondaySchool 1JohnYes
    2MondaySchool 1JackNo
    3MondaySchool 1JillNo
    4MondaySchool 2ChrisYes
    5MondaySchool 2ClintYes
    6TuesdaySchool 1JohnYes
    7TuesdaySchool 1JackYes
    8TuesdaySchool 1JillYes
    9TuesdaySchool 2ChrisNo
    10TuesdaySchool 2ClintYes

    etc.

     

    *Day is not including in the formula to simplify this

     

    Your suggestion would works well if I do not group by school name and presents the table as it is, but in this case this formatting would be part of the requirements. Do you think it can be achievable? 

     

    Regarding the names, yes, I am aware of that. This is only a demo to replicate the problem, original names are slightly different 🙂

     

    Kind Regards

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @Sam4 ,

    Please note I cannot test this and it may not work, but it might give you an idea.

    ForAll(
     AddColumns(
     galChild.AllItems,
     "Chosen",
     Dropdown2.Selected.Value,
     "PSchool"
     Parent.School
     ),
     Patch(
     TEst_School,
     Defaults(TEst_School),
     {
     School:PSchool
     Name_ID:name,
     Value:Chosen
     }
     )
     )
    ) 

     

    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.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Sam4 

    It looks to me like you have one table that includes students and schools.  If the relationship between schools and students is one to many, then your basic design is flawed and you will require at least two tables to describe the relationship between schools and students.  If the relationship between students and schools is Many to Many (ie. one student can have many schools and one school can have many students), then you will require three tables. Before further development of your app, I suggest you review my series of posts regarding the fundamentals of database design starting with the overview. https://powerusers.microsoft.com/t5/News-Announcements/Database-Design-Fundamentals-and-PowerApps-An-Overview/ba-p/184485 .  The student:teacher:classroom model is a classic in database design.  

  • Sam4 Profile Picture
    229 on at

    Thanks @WarrenBelz, I'm still getting some errors with the Parent.School I'll try to figure another way, but in any case thanks for the hint. I think the problem is on how the subgallery is created with the GroupBy, good for visualization but not for data input. 

     

    Hi @Drrickryp, thanks for your comments. I'm aware of the issues :), this is not a final app but a testing to implement a ForAll patching with subgalleries. Data model for the final solution is nothing to do with this example.   

     

    Kind Regards

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    Hi @Sam4 ,

    A bit hard to visualize your structure completely, but all you need to do is get the school related to the child gallery into the Patch.

    So I will pose something else to you - can you get that value into the data for the child gallery when you form the data source - it does not need to be displayed.

     

     

  • mayalghamdi Profile Picture
    40 on at

    Hi WarrenBelz, 

     

    sorry to have resurrected an older thread but i am having the same exact issue as the Sam4 except i dont have reserved words in my code. any idea why else that could be happening? 

  • WarrenBelz Profile Picture
    156,532 Most Valuable Professional on at

    @mayalghamdi ,

    Please post this as a new thread (reference this one for information if you want to)

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard