cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
biterbit
Kudo Collector
Kudo Collector

How to detect new record after submission

I've found a bug in some of my code that runs after a form submission. The code works fine for an edited record but not for a new record. For the existing record, the code is run if a field has changed; for a new record, it should always run. My code was using a test based on the form's mode being New - but I've realised that this does not work after form submission, as this automatically resets its mode to Edit.

Is there a way, after submission, to detect that a new record has been submitted other than by setting some variable before submission to track this?

1 ACCEPTED SOLUTION

Accepted Solutions
biterbit
Kudo Collector
Kudo Collector

@Drrickryp Thanks for your response. Actually, my question was about how to detect that the record was created rather than updated, rather than how to access the saved values. The only way I have found is to store the current form mode in a variable before the SubmitForm statement so I can use it later in the post-submit logic.

View solution in original post

2 REPLIES 2
Drrickryp
Super User
Super User

@biterbit 

If you Set(var, Form1.LastSubmit) in the OnSuccess property of the form this will identify the last submitted new record.

biterbit
Kudo Collector
Kudo Collector

@Drrickryp Thanks for your response. Actually, my question was about how to detect that the record was created rather than updated, rather than how to access the saved values. The only way I have found is to store the current form mode in a variable before the SubmitForm statement so I can use it later in the post-submit logic.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,236)