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 / Using Patch Defaults, ...
Power Apps
Answered

Using Patch Defaults, or update current item

(0) ShareShare
ReportReport
Posted on by 170

I have a canvas app where I am not using forms, but just containers with controls, etc.  On it, I have a SAVE button. I need to check if a record is already saved and if it is (I use a GUID for identification for the SharePoint list item) then do a patch to that item, and not a defaults.  Without writing a lengthy Patch statement TWICE with an if statement, is there a better way, or best practice to do this, or should I just do an if and copy the patch statement twice: one with the DEFAULTS (if it is a new record), and another with the patch (this item)?

 

Thanks for the information.

Categories:
I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @CMSGuy - 

     

    The Patch function requires three parameters (source, record, update).  

     

    One method is simply use the IF function to identify if the record exists. If the record exists, then reference the record, otherwise return Defaults.

     

    Basic example below:

     

    Patch(
     'Your List',
     If(
     IsBlank(
     LookUp(
     'Your List',
     ID = 100
     )
     ),
     Defaults('Your List'),
     LookUp(
     'Your List',
     ID = 100
     )
     ),
     {
     Title: "A1",
     DateColumn: Today()
     }
    )

     

    The alternative example below is virtually the same as the above, but written in a more legible structure using the With function so we can avoid using the same LookUp function twice:

     

    With(
     {
     _get_record: LookUp(
     'Your List',
     ID = 100
     )
     },
     Patch(
     'Your List',
     If(
     IsBlank(_get_record),
     Defaults('Your List'),
     _get_record
     ),
     {
     Title: "A1",
     DateColumn: Today()
     }
     )
    )
    

     

  • CMSGuy Profile Picture
    170 on at

    Thanks Imran for the explanation.  I will be using the With statement.  I always forget about using it.

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

Haque 85

#2
WarrenBelz Profile Picture

WarrenBelz 76 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard