Tuesday, March 4, 2014

Super() method in AX 2012

Super() method in AX 2012




 
Basically we can use super() in terms of inheritance.It is nothing just a parent call from a child method.Lets take couple of examples

Example 1:
Use of super() in Form’s method.
I have a form called ‘JournalizingDefinition’ ,contains many methods  under a Methods node.







When click on method node we will see
















So lets view the method called ‘init’(when form initializes ,this first method that is called is init method)


So there is super method, so the reason why super() is here,is that on creation of an instance of the any form, this super() method called the parent kernel method ‘loadUserSetting’ method of the SysSetupFormRun class,which creates and loads the form which is necessary otherwise form wont be initalize.Try to comment this super() method and open the form…

Example 2:
Use of super() in Form’s datasource method

JournnalizingDefinition form has multiple datasources(tables) attach to it.















So lets focus on ‘JournalizingDefinition; datasource and click the methods notes you will see the above methods.
Notice there is a ‘validateWrite’ ,method in which a super() is called



Now navigate to the tables node and search for ‘JournalizingDefinition’ and click method nodes











You will see the same method ‘validateWrite as well.But this is the parent method.

Now go to Form’s dataSource JournalizingDefinition open the validateWrite method and select the super() method and insert breakpoint.



Now open the form and insert the record and save button.I will open the debug mode and super() method is higlighted


Now press F11.Now it will take you the parent method validateWrite of the table journalizingDefinition,
Below is the parent method under ‘JournalizingDefinition’ method
public boolean validateWrite()
{
    boolean ret;

    ret = super();

    return ret;
}

No comments:

Post a Comment