Investigating form events

We could use the debugger to trace through the events the system calls as part of handling the form. This can be difficult at first as the code jumps between methods on the form and the FormRun framework. We can also do this by simply overriding the key methods and displaying an info log message.

The command to display an info log message is info("Message to be displayed").

We will override the methods called by the event by adding the info command after the call to super(), as highlighted in the following lines of code:

{
    super();
    info("<message>");
}

Note

As this method is overridden from the base class, AX automatically adds a line to call super(). This will call the base class' method, executing the code that would have normally run. We would not normally remove this line in the case of forms and framework classes as it can produce unexpected and undesirable results.

To create the demonstration, follow these steps:

  1. This is a demonstration, so to make it easier to revert, we will work on a duplicate of the ConFMSVehicleGroup form. This is done by right-clicking on the form and selecting Duplicate.
  2. Rename the form to ConFMSTest.
  3. Right-click on Methods, which is under ConFMSTest, and navigate to Override method | init.
  4. After the super() method call, add the following line:
    info("Form init called");
  5. Right-click on Methods, which is under ConFMSTest, and navigate to Override method | More… and then select run.
  6. After the super() call, add the following line:
    info("Form run called");

    Note

    This is placed deliberately after the super() call to highlight that the run method completes as soon as the form is displayed.

  7. Right-click on Methods, which can be found by navigating to ConFMSTest | Data Sources | ConFMSVehicleGroup, and navigate to Override method | write.
  8. After the super() call, add the following line:
    info("Data source write called");
  9. Right-click on Methods, which can be found by navigating to ConFMSTest | Data Sources | ConFMSVehicleGroup | Fields | Description, and navigate to Override method | modified.
  10. After the super() method call, add the following line:
    info("Data source field description modified");
  11. Right-click on Methods, which can be found by navigating to ConFMSTest | Designs | Design | GridContainer | Grid | Grid_Description | Methods, and navigate to Override method | modified.
  12. After the super() call, add the following line:
    info("Form control Grid_Description modified");
    1. Right-click on the ConFMSTest form and select Open. The system will display the following message in an Infolog window:
      Form init called
      Form run called
  13. Close the info log and click on New to create a new vehicle group record.
  14. Complete the Vehicle group and Description fields. Then, tab out of the Description field. This will show the following info log:
    Data source field description modified
    Form control Grid_Description modified
  15. Close the info log and click on New again as if you are to create a new vehicle group. This causes the form to save the new vehicle group and display the following info log:
    Data source write called

These events also carry on to the table, as shown in the following simplified diagrams:

Investigating form events
Investigating form events

To delete the form, simply right-click on the form and choose Delete. If this is done from the project, we are asked if we wish to remove the object from the project or delete it. In our case, we wish to delete the object.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.10.66