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 / 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
    153,529 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

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
Kalathiya Profile Picture

Kalathiya 428

#2
WarrenBelz Profile Picture

WarrenBelz 374 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 333 Super User 2025 Season 2

Last 30 days Overall leaderboard