Thursday 13 June 2019

Method Sequences when a Form is opened and Closed

An event method sequence is executed when a form is opened. The specific sequence depends on the set of controls and data sources that are associated with the form.

Open a Form

In this example, the user opens a form that contains a grid control, which is bound to a data source.
The executed events are distributed across two threads. The timing of event method execution between threads can vary.
The following table shows the sequence that event methods are executed in when a user opens a form.
Method
Where
Thread number
new
Form
init
Form
1
loadUserSetting
Form
2
run
Form
1
init
Data source
2
executeQuery
Data source
2
leaveRecord
Data source
2
leave
Data source
2
leaveRecord
Data source
2
firstField
Form
2
firstField
Form
1

Most forms in Microsoft Dynamics AX are closed when a user clicks the Close button (the standard button in the upper-right corner of most windows). Some forms can be closed by clicking either an OK or a Cancel button. When the form is closed, event methods are executed.

Close the Form by Using the Cancel Button

When a user closes a form by clicking the Cancel button, event methods are executed in the following sequence:
  1. closeCancel on the form.
  2. canClose on the form.
  3. close on the form.
 Note
The FormRun class has the closed method and the closedCancel method. These event methods are not executed when the Cancel button is clicked.
When a form is closed with the closeCancel event method, the user's changes are not saved.

Scenario

This scenario uses a form that contains one CheckBox control as its only control. Assume that the CheckBox control is bound to a form's data source and that the control can update the data source.

Aa602745.collapse_all(en-us,AX.60).gifClose the Form by Using the Close Button

When a user closes a form by clicking the Close button, event methods are executed in the sequence shown in the following lists. These lists are based on the previous scenario.
Following is the sequence of event methods when the form is closed—without the user clicking the check box.
  1. canClose on the form.
  2. leave on the check box.
  3. leave on the check box.
  4. leave on the data source.
  5. leaveValidate on the data source.
  6. leave on the check box.
  7. leave on the check box.
  8. close on the form.
  9. saveUserSetting on the form.
Following is the sequence of event methods when the form is closed—after the user has clicked a check box.
  1. canClose on the form.
  2. leave on the check box.
  3. leave on the check box.
  4. validateWrite on the data source.
  5. Write on the data source.
  6. update on the table.
  7. leaveRecord on the data source.
  8. leave on the data source.
  9. leaveRecord on the data source.
  10. leave on the check box.
  11. leave on the check box.
  12. close on the form.
  13. saveUserSetting on the form.

Aa602745.collapse_all(en-us,AX.60).gifClose the Form by Using the OK Button

Some forms can be closed by clicking an OK button. This leads to almost the same event method sequence as shown in the Close the Form by Using the Close Button section. The only difference is that clicking the OK button causes the Form.closeOK event method to be executed first.





1


No comments:

Post a Comment

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...