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 / Gallery Patch function...
Power Apps
Unanswered

Gallery Patch function copying same data from last row to sharepoint

(0) ShareShare
ReportReport
Posted on by 237

I have been trying to patch my repeating table (gallery with multiple rows) to my SharePoint list, however it keeps copying the data from the last row to all of the added rows.  See code for submit button, add event button, and the results of the patch button.

Additionally, the two collections in the app are blank when clicking the patch button. It only shows one column populated.

Help on this will be greatly appreciated!

 

Add event button:

NPatel12498_0-1680029436255.png

 

 

Submit Button:

NPatel12498_1-1680029494627.png

 

 

Gallery:

NPatel12498_2-1680029562581.png

 

 

ColSelectedMeals:

NPatel12498_4-1680029177209.png

ColMealDetails:

NPatel12498_3-1680029603271.png

 

 

 

SharePoint List after Submit button (patch)

NPatel12498_0-1680030081701.png

 

 

 

Categories:
I have the same question (0)
  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    Hi @NPatel12498 ,

     

    Try inserting ThisRecord. before each field value in the Patch function. Like that you are referring to the current record in the ForAll loop instead of the controls in the gallery (where automatically the values of the last item are used). For instance:

     

    Title: ThisRecord.TitleID.Text

     

  • NP-18101421-0 Profile Picture
    237 on at

    This causes errors:

     

    NPatel12498_0-1680033672015.png

     

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    HI @NPatel12498 ,

     

    How are the values in the gallery saved to the collection? Having had a better look at your screenshots, it seems you're trying to patch an empty collection to the data source: there's nothing in colMealDetails.

     

    If you haven't done so already, set the OnChange property of the input controls in the gallery to something like the below:

     

    Patch(
     ColMealDetails,
     ThisItem,
     {
     TitleID: ThisItem.TitleID.Text,
     EventDate: Text(ThisItem.Evendate.SelectedDate),
     RequiredMeals: Concat(ThisItem.ComboBox.SelectedItems, Value, ", "),
     EventDuration: ThisItem.EventDuration.Text,
     ***Attendees: ThisItem.***Attendees.Text,
     Non***Attendees: ThisItem.Non***Attendees.Text
     }
    )

     

    This should properly populate the collection. 

     

    To then submit the collection to the DataSource, you can leave out the .Text, i.e.:

     

    TitleID: ThisRecord.TitleID,
    EventDate: ThisRecord.EventDate,
    etc. etc.

     

    The above works on the assumption that all columns are text types. In case you have other types as well, please share which columns have which types.

  • NP-18101421-0 Profile Picture
    237 on at

    The event date is a date type and the required meals is a multi select choice column

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    Hi @NPatel12498 ,

     

    In that case the below is worth trying to set as the OnCHange property of the input controls in the gallery:

     

    Patch(
     ColMealDetails,
     ThisItem,
     {
     TitleID: ThisItem.TitleID.Text,
     EventDate: ThisItem.Evendate.SelectedDate,
     RequiredMeals: ThisItem.ComboBox.SelectedItems,
     EventDuration: ThisItem.EventDuration.Text,
     ***Attendees: ThisItem.***Attendees.Text,
     Non***Attendees: ThisItem.Non***Attendees.Text
     }
    )

     

  • NP-18101421-0 Profile Picture
    237 on at

    HI there are still errors with this code

    NPatel12498_0-1680097690642.png

     

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    HI @NPatel12498 ,

     

    What errors are you receiving?

     

    You do have to make some modifications to the formula because some identifiers of controls were not given or stricken:

     

    ComboBox: the control where you select the meals

    1st ***Attendees: Column name

    2nd ***Attendees: the control where the number of ***Attendees is given

    1st Non***Attendees: Column name

    2nd Non***Attendees: the control where the number of Non***Attendees is given

     

    Also please correct any typing mistakes: I'm doing this in a notepad, so nothing to correct any mistakes.

  • NP-18101421-0 Profile Picture
    237 on at

    Hi,

     

    I have adjusted the formula with the correct column names but it is still giving me errors. 

     

    NPatel12498_0-1680100981394.png

     

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    Hi @NPatel12498 ,

     

    Can you share the formula please?

  • NP-18101421-0 Profile Picture
    237 on at
    Patch(
     ColMealDetails,
     ThisItem,
     {
     TitleID: ThisItem.TitleID,
     EventDate: ThisItem.Evendate,
     RequiredMeals: ThisItem.RequiredMeals,
     EventDuration: ThisItem.EventDuration,
     ****Attendees: ThisItem.****Attendees,
     Non****Attendees: ThisItem.Non****Attendees
     }
    )

     

    The code has less errors after I take out the .text, .selecteddate out of the formula. But this is what I have currently and it is still throwing errors. Disregard the **** that is just data protection on my end. 

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard