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:
  • Verified answer
    WarrenBelz Profile Picture
    156,921 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

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 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard