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 / Upsert / Updating a re...
Power Apps
Unanswered

Upsert / Updating a record

(0) ShareShare
ReportReport
Posted on by 72

Hi, hopefully someone can help me! 

 

I have created a Timesheet logging app, and the records of this are being stored in a SharePoint list named "TimesheetEntries".

At the moment when a user edits their timesheet to add a new record within the app it creates duplicate records in the SharePoint list and I would like for it to instead update the records.

 

What I've done so far is upon saving the timesheet I've used an If and IsBlank function so if the ID column is blank it will create a new record and if there is an ID present in the SP list it will not duplicate the record. So when adding a new record to the timesheet it will add it to the SP list as it does not have an ID yet and it will not duplicate the other existing records.

 

But this function does not work if I change something within an already existing record.

If I change a record it will create a new record with all the same info apart from the one thing I have changed.

Obviously, it needs a different function or I need to add something but I'm not too sure what.

 

What's making it quite difficult is the timesheet lines are different records within the SP list.

 

In the screenshot, I'm using the green save button to test and the "Text_ID_1" field is showing the SP record ID.

Categories:
I have the same question (0)
  • Verified answer
    gcmfaizan Profile Picture
    1,022 on at

    @caoimhelambert insted using the if condtion inside the patch function use it outside the patch function something look like this:

    If(
     IsBlank(Text_ID_1.Text), // Check if ID is blank (new record)
     Patch(
     TimesheetEntries, // Your SharePoint list
     Defaults(TimesheetEntries), // Create a new record
     {
     Title: TextInput_Title.Text,
     HoursWorked: TextInput_Hours.Text,
     // ... and so on
     }
     ),
     Patch(
     TimesheetEntries,
     LookUp(TimesheetEntries, ID = Value(Text_ID_1.Text)), // Find the record to update
     {
     // Update the fields that need to be changed
     Title: TextInput_Title.Text,
     HoursWorked: TextInput_Hours.Text,
     // ... and so on
     }
     )
    );

    currently, you are checking is Text_ID_1 is blank and then creating a new record, but for updating you are not giving the ID of the record you want to update. I hope the above formula helps you.

     

     

    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

     

    Thanks!

  • caoimhelambert Profile Picture
    72 on at

    @gcmfaizan that worked! Thank you very much!

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