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 / For All - Patching Rec...
Power Apps
Answered

For All - Patching Records

(0) ShareShare
ReportReport
Posted on by 2
Hello, I am attempting to make a timesheet canvas app connected to Dataverse.   I am using the code below to update existing records.  It seems to work fine when adding a new line and saving initially.  After I press make an update and save again, it simply saves the data in the second record to the first record and clears out the original data in the first record.
 
ForAll(
    Filter(
        colUpdateTimesheetLines As Timesheet,
        !IsBlank(Timesheet.TimesheetID) // Identify existing records
    ),
    With(
        {
            ExistingRecord: LookUp('DEV-TIMESHEETS', cr359_timesheetid = TimesheetID)
        },
        Patch(
            'DEV-TIMESHEETS',
            ExistingRecord,
            {
                Owner: CurrentUser,
                Sun: Sun,
                Mon: Mon,
                Tues: Tues,
                Weds: Weds,
                Thurs: Thurs,
                Fri: Fri,
                Sat: Sat,
                'Hours Worked': Total
            }
        );
        Notify("Existing record updated with TimesheetID: " & TimesheetID, NotificationType.Information)
    )
);
 
 
First Save:
 
After saving again:
Collection shows original:
Any help will be appreciated!  Thank you
Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,471 Most Valuable Professional on at
    You need to identify the existing record in relation to the ForAll value being processed. Also the Notification inside the ForAll is not much use as you will only see the last one.
    ForAll(
       Filter(
          colUpdateTimesheetLines,
          !IsBlank(TimesheetID)
       ) As Timesheet,
       With(
          {
             ExistingRecord: 
             LookUp(
                'DEV-TIMESHEETS', 
                cr359_timesheetid = Timesheet.TimesheetID
             )
          },
          Patch(
             'DEV-TIMESHEETS',
             ExistingRecord,
             {
                Owner: CurrentUser,
                Sun: Sun,
                Mon: Mon,
                Tues: Tues,
                Weds: Weds,
                Thurs: Thurs,
                Fri: Fri,
                Sat: Sat,
                'Hours Worked': Total
             }
          );
          Notify(
             "Existing record updated with TimesheetID: " & TimesheetID, 
             NotificationType.Information
          )
       )
    );
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    Buy me a coffee

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard