Bendrinti naudojant


Main Class Design Pattern

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

Use the main class design pattern whenever a class is called from a menu item.

Do not call the main method explicitly from the code; call it implicitly it from a menu item.

The following list describes how to implement the main class design pattern:

  • Instantiate the class by calling the static construct method.

  • Call the prompt method to create a dialog box.

  • If the user clicks OK in the dialog box, call the run method.

Most classes that have a main method are candidates to be implemented by the RunBase framework.

Tip

A code editor script can be used to create the main method. In code editor, press Alt + M to open the editor scripts menu, and then select template > method > main.

See also

Best Practices for Static Construct Methods

Methods in X++

RunBase Class

How to: Access a Class from a Menu

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.