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:
Form1
Set(LastRecord, Form1.LastSubmit);
Navigate(Screen1);
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!
Set(
varRecord,
Self.LastSubmit
)
varRecord.FieldName
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional