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

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

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard