Skip to main content
Community site session details

Community site session details

Session Id : E+x4EEsllEm/hqo0V+LYls
Power Apps - Building Power Apps
Answered

Populate NewForm with last submission

Like (0) ShareShare
ReportReport
Posted on 30 Sep 2022 17:01:23 by 6

Hi, 

Wondering if this is possible...Relatively new to PowerApps, but I've looked and having trouble finding an answer.

 

I'm using a somewhat basic View/Edit/NewForm, although it does have date picker and a few dropdowns. The user just told me they often submit batches of entries that are mostly the same, so they'd like to have a button to pre-fill a NewForm with the last submission and just make minor changes before submitting.

 

I've tried using LastSubmit, but that gets wiped out any time you switch to NewForm mode. Considered passing all values to variables, but there are quite a few, so wondering if there's a cleaner way to solve. 

 

Thanks!

  • Slamrc Profile Picture
    6 on 03 Oct 2022 at 16:52:50
    Re: Populate NewForm with last submission

    That helps a lot, thanks @RandyHayes!

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 03 Oct 2022 at 16:46:26
    Re: Populate NewForm with last submission

    @Slamrc 

    It is all a matter of providing the ID!!  This is true for Forms and for the Patch function as well.

     

    If you provide the primary key (ID in this case) then the Form will submit and update the existing record (essentially what you call "Edit Mode").  If you provide a Blank ID, then the form will create a new record (what you call "New Mode")

    View mode is something completely different...the only thing that does is put the DisplayMode into View!

     

    So, with the form in Edit mode - If you provide this for the Item property (either directly or through a variable):

        Defaults(yourDataSource)

    Then even though the form is in "Edit Mode", it is still going to create a new record.

     

    If you provide this for the Item property:

       Patch(Defaults(yourDataSource), {Title: "Something"})

    Then it will also create a new record when submitted.  The advantage on this is that the Title column is already filled out.

     

    If you provide any other record with a valid ID, then you will just be editing the record as usual.

     

    Does that answer your concern?

     

     

  • Slamrc Profile Picture
    6 on 03 Oct 2022 at 15:20:42
    Re: Populate NewForm with last submission

    Thanks @RandyHayes, that might work but just wondering...

     

    You mentioned to keep it in Edit mode as the above solution will always submit a new record. What I'm trying to accomplish is for the form to be able to:

     

    1) View

    2) Edit existing records

    3) Submit new record (starting from blank form)

    4) Submit new record (copied from previous if user selects that option).

     

    If the form is always submitting a new record, seems like I wouldn't be able to edit existing? Probably need to change button function conditionally based on user selection, along with conditionally changing the Item between blank and "copy from previous".

     

    Appreciate the help, think this definitely gets me closer, I'll test it today.

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 30 Sep 2022 at 20:04:59
    Re: Populate NewForm with last submission

    @Slamrc 

    Yes, this is quite basic to do.  The trick is to hold on to the Last Submitted record from your form.

    To do that, make sure you have a formula such as this in your OnSuccess action of your form:

        Set(glbRecord, Self.LastSubmit)

     

    Now, for your Item property of your form, you would simply patch in the values from the last submit that you would like.  

    For example, if you have a Title and an EntryDate column in your record that you want to persist to another entry, then you would do the following in your Item property of your Edit Form.

    Patch(Defaults(yourDataSource), {Title: glbRecord.Title, EntryDate: glbRecord.EntryDate})

     

    NOTE: Keep your for in Edit mode all the time.  Ignore using New form as the above formula will always be providing a New record.

     

    One additional note, if you want the entire record last submitted to be used again, then change your Item property formula to:

    Patch(glbRecordm {ID: Blank()})

     

    I hope this is helpful for you.

     

  • timl Profile Picture
    35,202 Super User 2025 Season 1 on 30 Sep 2022 at 19:00:37
    Re: Populate NewForm with last submission

    @Slamrc 

    One way to do this is to add an edit form to a screen. Set the DataSource property to your data source and the Item property to the following:

    Coalesce(varLastSubmit, Defaults(YourDataSource))

    For your save button, add the following formula (rather than calling SubmitForm)

    Set(varLastSubmit,
     Patch(Product, Defaults(YourDataSource),EditForm1.Updates)
    )

     

  • Manan-Malhotra Profile Picture
    621 Super User 2024 Season 1 on 30 Sep 2022 at 17:09:20
    Re: Populate NewForm with last submission

    1. Create a View Form

    2. Add a datasource to that form with the below filters

    Last(Sort(Datasource_Name,createdon,Ascending))

    Hope this helps!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1

Loading complete