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 / Patch Responses from A...
Power Apps
Suggested Answer

Patch Responses from Apps to Sharepoint

(0) ShareShare
ReportReport
Posted on by 8

Hi everyone,

I'm building a supplier performance evaluation app in Power Apps and need some help with patching data to SharePoint.

In my app, KPI data is pulled from one SharePoint list, and user responses (i.e., scores) need to be patched into a separate SharePoint list. I've structured the app using a vertical gallery nested inside another vertical gallery.

Currently, I'm having trouble patching the responses correctly into the destination list. I've attached a screenshot of the layout for reference.

Has anyone worked with nested galleries in Power Apps and successfully patched data to SharePoint? I'd appreciate any guidance or examples. Thanks in advance!

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,433 Super User 2025 Season 2 on at
     
    Can you please be more specific with exactly is not working. The images may or may not ever come in so need to see the code you are doing (so I dont have to write it up manually) and whatever error you are getting.
     
    While there should be no problem patching I cannot see yet how you are even attempting it. Are you doing a ForAll with a nested ForAll?
     
    Doing what you explain isn't an issue, there is one specific scenario that we may need to work with Alias's but other than that there should be no issues, many do nested gallery inserts
  • JN-06050033-0 Profile Picture
    8 on at

    Hi Michael, thank you for your reply!

    Yes, I’m using a nested ForAll to patch KPI scores from a nested gallery setup. Here’s the actual code I’m working with:

    ForAll(
        gal_KPICategory.AllItems,
        ForAll(
            ThisRecord.gal_KPIItems.AllItems,
            Patch(
                IDM_KPI_Responses,
                Defaults(IDM_KPI_Responses),
                {
                    Title: "Response", // Placeholder
                    Supplier_Name: varSelectedSupplier,
                    Category: ThisRecord.KPI_Category,
                    KPI_Name: gal_KPIItems.Selected.KPI_Name,
                    Score: gal_KPIItems.Selected.Score_Input
                }
            )
        )
    )

    The outer gallery (gal_KPICategory) displays KPI categories like Cost, Resilience, Sustainability, etc. Inside it, gal_KPIItems lists the KPIs under each category. Each KPI row has a text input or dropdown for the score (Score_Input).

    The issue: when I click submit, nothing gets written to the IDM_KPI_Responses SharePoint list. There’s no error, just no data patched.

    Thanks again for your help!

     

     

  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,433 Super User 2025 Season 2 on at
     
    So you have a bunch of Context Data issues.
     
    Here is your Code
     
    Problems:
    1. you are looping through all the gal_KPIItems.AllItems but you are assigning KPI_Name for instance to gal_KPIItems.Selected.KPI_Name. This will not work, as it will only ever give you the row that is selected, and not the CURRENT row within the loop
     
    2. In the Category you have ThisRecord.KPI_Category, I have have to assume this come from the gal_KPICategory? Which is the Parent (outer loop) but you have ThisRecord, but in your code, ThisRecord is pointing to the current loop of gal_KPIItems.AllItems.
     
    So there are multiple things that will make this not work. I am not even sure you are getting into the Patch loop to begin with.
    ForAll(
        gal_KPICategory.AllItems,
        ForAll(
            ThisRecord.gal_KPIItems.AllItems,
            Patch(
                IDM_KPI_Responses,
                Defaults(IDM_KPI_Responses),
                {
                    Title: "Response", // Placeholder
                    Supplier_Name: varSelectedSupplier,
                    Category: ThisRecord.KPI_Category,
                    KPI_Name: gal_KPIItems.Selected.KPI_Name,
                    Score: gal_KPIItems.Selected.Score_Input
                }
            )
        )
    )
    
    
    Using Context: I updated it below
     
    You will have to complete the updates as you cannot use .Selected you need to use the proper Control OR just a point to the row.
    The pointer to the row is normally ThisRecord, but since its an inner loop, and I added alias's its _Parent or _Child
    And assuming that Score_Input is a direct property of the Row (in the loop) or aka ThisRecord, aka _Child, then its just .KPI_Name etc
    IF these values are in text boxes or labels or whatever then you would do
     
    _Child.ControlName.PropertyToGrabValueFrom
    ForAll(
        gal_KPICategory.AllItems As _Parent,
        ForAll(
            _Parent.gal_KPIItems.AllItems As _Child,
            Patch(
                IDM_KPI_Responses,
                Defaults(IDM_KPI_Responses),
                {
                    Title: "Response", // Placeholder
                    Supplier_Name: varSelectedSupplier,
                    Category: _Parent.KPI_Category,
                    KPI_Name: _Child.KPI_Name,
                    Score: _Child.Score_Input
                }
            )
        )
    )
     
    Another thing is you can simply validate that you are getting to the Child, even though the code is not correct, by doing this.
    1. Update your code as such
    ForAll(
        gal_KPICategory.AllItems,
        ForAll(
            ThisRecord.gal_KPIItems.AllItems,
            Trace("I am in the child loop and patch is next");
            Patch(
                IDM_KPI_Responses,
                Defaults(IDM_KPI_Responses),
                {
                    Title: "Response", // Placeholder
                    Supplier_Name: varSelectedSupplier,
                    Category: ThisRecord.KPI_Category,
                    KPI_Name: gal_KPIItems.Selected.KPI_Name,
                    Score: gal_KPIItems.Selected.Score_Input
                }
            )
        )
    )
    
    
     
    Now, these Steps (Assumes you are in Dev Mode) NOT play made
    1. Publish your App
    2. Click the Stethescope
    3. Click Live Monitor
    4. Soon as Live Monitor Triggers
    5. Run your code and make sure the changes above would be triggered
    6. Go to Live Monitor Tab in browser
    7. In Filter Type Trace
    See if anything shows up. If NOT then you are not getting to the loop so no way to get data
     
    If you are seeing them then do this next
    8. Change filter to Error
    See if you see errors, if nothing, thats fine,  your code still technically shouldn't work correctly, I just wanted to show you how you could valdiate  your code is being reached.
     
    Make the changes per my code and directions on Controls and Properties and see if it works.
     
    If Not, there is a platform known issue, where sometimes inner loops like this actually act like there is no data. So the AllItems for your child, will NOT do squat as it acts like there is nothing
     
    To fix this we have to add something to the Parent (for instance, hide a label) in it put Text(CountRows(ThisItem.gal_KPIItems.AllItems))
     
    And try again and if you all of a sudden see data then you have both issues (your code is incorrect) and the platform issue. Just fix one at a time.
     
    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.
    Thank you!
    Sincerely, Michael Gernaey

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard