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 adding a new rec...
Power Apps
Answered

Patch adding a new record instead of updating a Sharepoint List

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi everyone, 

I have been following this tutorial until 15min30 : https://www.youtube.com/watch?v=76RJyaoW0BQ

since this grid linked with Sharepoint List is exactly what I need.

However, instead of having my rows updated like in the video (still 15min30), it does not take into account the changes that were made and duplicates the lines where some changes happened.

To illustrate, I start with this : PowerAppsIssue1.PNG

Then check "HE" while my app is running : PowerAppsIssue2.PNG

And when I click on save, it duplicates "Material1" with its initial values: 

PowerAppsIssue3.PNG

Nevertheless, I did not change much the code from the tutorial :

The OnSelect that fills the collection colGridUpdates (with invisible button): 

 

If(
IsBlank(
LookUp(
colGridUpdates,
ID = ThisItem.ID)
),
Collect(
colGridUpdates,
ThisItem)
);

UpdateIf(
colGridUpdates,
ID = ThisItem.ID,
{
Title: TextInputTitle.Value,
KE: CBKE.Checked,
HE: CBHE.Checked,
Grenze: Value(TextInputGrenze.Value),
Komponente:CBKomponente.Checked
}
);

 

 

The OnSelect on the Save Button : 

 

Patch(
 ListMaterials,
 ShowColumns(
 colGridUpdates,
 "Title",
 "KE",
 "HE",
 "Grenze",
 "Komponente"
 )
);

Notify("Grid saved", NotificationType.Success, 3000);
Clear(colGridUpdates);
Set(varReset, false);
Set(varReset, true);

 

If I understood well, on this Patch, ListMaterials should be updated based on colGridUpdates, with the columns I selected from it (in my case I wanted all the columns from colGridUpdates).

 

I feel stuck, thank you in advance to whom may help!

Categories:
  • developerAJ Profile Picture
    4,763 on at
    Patch(
     ListMaterials,
     ShowColumns(
     colGridUpdates,
     "Title",
     "KE",
     "HE",
     "Grenze",
     "Komponente"
     )
    );

     

    add ID column ID is primary column without ID it will create new records

     

  • Verified answer
    Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @Anonymous ,

     

    You need changes in the code:

    For you invisible button:

    If(
     !(ThisItem.ID in colGridUpdates[@ID]),
     Collect(
     colGridUpdates,
     {
     ID : ThisItem.ID,
     Title: TextInputTitle.Value,
     KE: CBKE.Checked,
     HE: CBHE.Checked,
     Grenze: Value(TextInputGrenze.Value),
     Komponente:CBKomponente.Checked
     }
     ),
     With(
     {
     Record: LookUp(colGridUpdates, ID = ThisItem, ThisRecord)
     },
     Patch(
     colGridUpdates,
     Record,
     {
     Title: TextInputTitle.Value,
     KE: CBKE.Checked,
     HE: CBHE.Checked,
     Grenze: Value(TextInputGrenze.Value),
     Komponente:CBKomponente.Checked
     }
     )
     )
    );

     

    For your save button,

    IfError(
     Patch(
     ListMaterials,
     colGridUpdates
     ),
     Notify("Error Occured", NotificationType.Error, 1000);
     false;
     ,
     Notify("Grid saved", NotificationType.Success, 2000);
     Clear(colGridUpdates);
     true;
    )

     

    Hope this helps

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ok, I had to add an ID. Thanks to both of you, and your code @Ethan_R is really cool. 

  • developerAJ Profile Picture
    4,763 on at

    Yep Adding ID should be sufficient

  • irishpowerapp79 Profile Picture
    2 on at

    Hi, would you be able to share your final solution code for the 2 buttons. I am in the exact same position as you were after watching the same video and its so frustrating! 🙂

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard