Calling Static X++ Methods [AX 2012]
Updated: January 16, 2012
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
From within code for a User Control, you can call static X++ methods for classes and tables. The Session object provides access to the AxaptaAdapter object. The AxaptaAdapter object has methods that you can use to call static X++ methods. See Session Object for detailed information about how to retrieve the Session object.
To call a static method for a class, use CallStaticClassMethod() from the AxaptaAdapter object. For example, the following code defines the static method named triple for the Example class. This simple method triples the value that is passed to it.
The following code for a button in a User Control takes the text from the IntValue text box. It converts it to an integer, and then uses CallStaticClassMethod() to call the triple static method that is defined for the Example class. The result is displayed in the text box.
To call a static method for a table, use CallStaticRecordMethod() from the AxaptaAdapter object. For example, the following code for a button in a User Control takes the text from the CustAccount text box. It uses CallStaticRecordMethod() to call the exist static method that is defined for the CustTable table. If the customer account exists, true is returned. Otherwise, false is returned. The result is used to set the value of a check box.