When the user clicks New (or the form is opened with a menu item that has Open Mode set to Yes), the form triggers a task that calls the current data source's Create method. In our case, we must let the data source do this; however, at this point, we will open the create dialog using the Create method we wrote on the form handler.
The Create method is a standard way to call any form from code. Never use the form name as a string literal without using a compile-time function, in this caseĀ formStr.
This calls the create dialog, which is set up so that the normal form events no longer fire. We will initialize the form from the form handler class in order to pass the new record back.
Once control returns to our details form, we will replace the data of the record with the record we created with the create dialog; this was done in the data([Common]) method.
The key activities can be seen in this diagram:
Understanding the control flow for form events is important when writing code. It is very easy to get unexpected results, should we not follow this pattern. Some examples are that the newly created record is not shown to the user after the record has been created by the Create form or that a blank record is shown if the user presses cancel on the create form.