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 Apps
Answered

Patch function

(0) ShareShare
ReportReport
Posted on by 4
Hey all,
 
Is it possible to use a patch function on a form to only create a new record rather than creating a new record and modifying the existing one?

Best regards,
Frederik
Categories:
I have the same question (0)
  • Verified answer
    Sarah Guest 20 Profile Picture
    27 on at
    Hi Frederik, 
     
    When you are using the Patch function you can pass an empty record as the second argument to create a new record
     
    Patch(
        YourDataSource, 
        Defaults(YourDataSource), 
        {Field1: "Value1", Field2: "Value2"}
    )
     
    When you are modifying an exisiting record you pass in a lookup for the record you want to update. 
     

    Patch(
    YourDataSource,
    LookUp(YourDataSource, ID = 123),
    {Field1: "UpdatedValue"}
    )
     
     
    Here is the Microsoft Learn link around patching. 
     
    When working with forms in Power Apps, the mode of the form determines whether a new record is created or an existing record is updated.
    New Form Mode (NewForm(FormName)) – Creates a New Record
    Edit Form Mode (EditForm(FormName)) – Updates an Existing Record
     
     
    I hope this helps!
     
     
     
     
  • Suggested answer
    Gabriel G. Profile Picture
    831 Moderator on at
    When you use a form, no need to use Patch. You simply configure which type of form you use (DefaultMode = FormMode.Edit or FormMode.New). Then, when you ready to save, you use SubmitForm(<formName>). If it is a FormMode.New, it is a new record, otherwise it is an update.
     
    __________________________________________
     
    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.
  • JH-20021340-0 Profile Picture
    4 on at
    @Sarah Guest 20

    I'm currently using that exact patch function formula but it still updates the existing record. 
     
    SubmitForm(formInspection);
    Patch(('Group Portfolio Projects - TO'),Defaults('Group Portfolio Projects - TO'),{'Project ID':Value(DataCardValue4.Text),Priority:Value(DataCardValue9.Text),'CXO priority':Value(DataCardValue6.Text),'Sponsor/Function':DataCardValue10.Selected.Value,'Portfolio Type':DataCardValue7.Selected.Value,'Who is managing the project':DataCardValue3.Selected.Value})

    Can you see if there's something wrong with my code?
     
    Best,
    Frederik

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard