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() not updating r...
Power Apps
Answered

Patch() not updating record but creates new one

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello Community,

 

Cannot figure what am I doing wrong with my patch function because instead of updating existing sharepoint item it is creating new one. 

SharePoint list:

CristianF_0-1646152788293.png

OnSelect button:

 

Patch('Time Records',LookUp('Time Records', 'Active Session'= true , {'End time': Now(), 'Time Spent': DateDiff(varNewItem.'Start time',Now(),Minutes), 'Active Session': false}))

 

 Result:

CristianF_1-1646152917391.png

 

I know that Defaults() function it is used for creating new item but i am not using it and still the button is creating new item.

All I want is the button to update or 'insert' data in 'End Time' and 'Time Spent' columns and switch 'Active Session' (Yes/No column type) from true(check mark) to false(no check mark).

  

Any help would be really appreciate since i'm struggling with this issue for quite some time ...

 

Thank you in advance !

Categories:
I have the same question (0)
  • Verified answer
    timl Profile Picture
    37,160 Super User 2026 Season 1 on at

    @Anonymous 

    The call to LookUp here is incorrect.

    If you want to update the first record in your SharePoint list where 'Active Session' is true, the syntax would look like this.

    Patch('Time Records',
     LookUp('Time Records', 'Active Session'= true) ,
     {'End time': Now(), 'Time Spent': DateDiff(varNewItem.'Start time',Now(),Minutes), 'Active Session': false}
    )

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @timl many thanks for your fast reply !

    Cannot belive that only some ( ) got me in all these trouble ... thank you so much, you saved me.

    Now the function is working as intended but the only thing now is that it is not calculating any more the time spent between start time and end time. Could you also help me solve this please ?

    CristianF_0-1646154285522.png

     

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard