Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Automatically populating a new form with last submitted on a button press - Dataverse

(0) ShareShare
ReportReport
Posted on by 67

Hello everyone,

I would like to enhance a canvas app by allowing users to press a button that will automatically populate a New Form with their previously submitted data the next time they go to submit a record. However, I'm at a loss at how to implement this.

Here’s the current setup:

  • Screen 1: Contains two buttons and a gallery (Gallery1) displaying records from a Dataverse table.
    • Button 1 ("New"; on Screen 1): Navigates users to another screen (Screen 2) with Form1 in New mode. The OnSelect property for this button is: NewForm(Form1); Navigate(Screen2)
    • Button 2 (inside the gallery): Each record in the gallery has this button. When clicked, it navigates users to Screen 2 with ‘Form1’ in Edit mode, allowing them to edit that record. The OnSelect property for this button is: EditForm(Form1); Navigate(Screen2)
  • Screen 2: Contains an Edit Form control called 'Form1' and a "Submit" button.
    • The Item property of Form1 is Gallery1.Selected
    • The OnSuccess property of Form1 is Navigate(Screen1)
    • The OnSelect property of the Submit button is SubmitForm(Form1)
So users will normally go to Screen 1, click the "New" button which will navigate them to Screen 2, fill out the form manually the first time, and click Submit, which will navigate them back to Screen1. The next time they click on "New' and navigate to Screen 2, I want them to be able to click a button called "Duplicate" that will automatically populate the form with what they submitted the last time. Is this possible? I looked into the LastSubmit function but it seems to only work with forms in Edit mode, which mine isn't.
 
Does anyone know how to accomplish this? I'd be very grateful for any assistance. Thank you very much in advance!
  • Verified answer
    SaiRT14 Profile Picture
    1,961 Super User 2025 Season 1 on at
    Automatically populating a new form with last submitted on a button press - Dataverse
     
    1. Capture the Last Submitted Record
    OnSuccess Property of Form1
    Set(LastRecord, Form1.LastSubmit);
    Navigate(Screen1);

     
    2. Modify the "New" Button
    Ensure that when users click "New", the form is reset to default values and any duplication flags are cleared:
    Set(isDuplicating, false);
    NewForm(Form1);
    Navigate(Screen2);
     
    3. Add a "Duplicate" Button

    Place the "Duplicate" Button on Screen1 or Screen2 Decide where you want the "Duplicate" button. If you place it on Screen1, set its OnSelect property as:

    Set(isDuplicating, true);
    EditForm(Form1);
    Navigate(Screen2);
     

    4. Set Up a Duplication Flag

    Use isDuplicating to track whether the form should pre-populate with the last submitted data.

    • Initialize the Variable - In the OnStart property of the app:

    Set(isDuplicating, false);
     

    5. Configure Form1 to Use the Last Record

    Item Property of Form1

    Set the Item property of Form1 to:

    If(isDuplicating, LastRecord, Blank())
     

    6. Modify the Submit Button to Create a New Record

    OnSelect Property of the Submit Button - Since the form is in Edit mode but we want to create a new record, use the Patch function:

    Patch(
        DataSourceName,
        Defaults(DataSourceName),
        Form1.Updates
    );
    ResetForm(Form1);
    Set(isDuplicating, false);
    Navigate(Screen1);
     

    7. Reset Duplication After Submission

    The Set(isDuplicating, false); line ensures that after submitting the duplicated data, the form doesn't retain the duplication state.

     

    8. Handle First-Time Users or No Previous Data

    Check if LastRecord is Available - In the OnSelect property of the "Duplicate" button, ensure LastRecord is not empty:

    If(
        !IsBlank(LastRecord),
        Set(isDuplicating, true);
        EditForm(Form1);
        Navigate(Screen2),
        Notify("No previous data to duplicate.", NotificationType.Warning)
    )
     

    By capturing the last submitted record and cleverly using form modes and variables, you can enhance your app to allow users to duplicate their previous submissions easily. This improves user experience by saving time and reducing data entry errors.

    Let me know if you have any questions or need further assistance implementing this solution!

     

  • WarrenBelz Profile Picture
    146,651 Most Valuable Professional on at
    Automatically populating a new form with last submitted on a button press - Dataverse
    If you set a Variable OnSuccess of Form1
    Set(
       varRecord,
       Self.LastSubmit
    )
    then you would set the Default (or equivalent) of each control in Form2 to (using the actual relevant field name)
    varRecord.FieldName
     
    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.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard