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 / Create NEW record when...
Power Apps
Unanswered

Create NEW record when existing record is edited

(0) ShareShare
ReportReport
Posted on by 69

Hi,

Using either Dataverse or SP as datasource.

How do I create a NEW record (with changes) when editing an existing record?

 

Or put another way, how do I retrieve the contents of an existing record, whereby the SAVE ("SubmitForm") function thereafter creates a NEW record with the same contents + any changes.

 

I have 45 Columns (fields), so something that doesnt require coding each datacardvalue would be preferred.

 

Thanks,

Jonathan

Categories:
I have the same question (0)
  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi @JonathanDavey1 ,

    You can use below formula in OnSelect property of duplicate button on your screen - 

    Patch(SPListName, Defaults(SPListName), Form1.Updates)

    Assumptions - 

    SPListName is Sharepoint List name or data source name

    You are using a form control in Edit Mode named "Form1" 

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @JonathanDavey1 

    Avoid using a Patch function on a form as it breaks the form functionality and features.

     

    In your case, look to the Item property of your form and keep your form in Edit mode all the time.

    If you have an existing record (let's say from a Gallery and on SharePoint), then the following formula in the Item property will provide what you want:

        Patch(yourGallery.Selected, {ID: Blank()})

     

    The key here is (no pun intended) the Primary Key column of your data source.  If it is Blank, than SubmitForm will know that it is a new record and create it.  If it has a value, then it will update.

     

    In the case of DataVerse, you do the same thing, but you need to determine the name of the primary key column (the unique identifier column) of the list and then just substitute it into the above formula.

     

    I hope this is helpful for you.

  • JonathanDavey1 Profile Picture
    69 on at

    Thanks Randy, sorry when you say formula the "Item" Property to:  Patch(yourGallery.Selected, {ID: Blank()}) 

    Can you be explicit please, is it the EditForm or the Datacard or the SubmitForm(EditForm1) OnSelect property.

     

    Thanks

    Jonathan

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @JonathanDavey1 

    Only the Form will have an Item property.  That is the one to change.

    If you are not sure what it should be, then what is the current formula in the Item property?

  • JonathanDavey1 Profile Picture
    69 on at

    EditForm1 - Item - BrowseGallery1.Selected
    Changed to: Patch(BrowseGallery1.Selected, {SimpleTest_Records: Blank()})

    Where "SimpleTest_Records" is the Unique Identifier for the DV Table.

     

    Throws an error (as attached).

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @JonathanDavey1 

    What is SimpleTest_Records?  Is this for Dataverse?

  • JonathanDavey1 Profile Picture
    69 on at

    @RandyHayes 

    Yes and the name of primary key column (as attached).

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard