How to: Add a Script to the Code Editor

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

Editor scripts help you to perform frequent tasks more quickly in the X++ code editor. They are accessed by clicking the Scripts button in the code editor window.

To create a new script:

  1. Add a new method to the EditorScripts class.

  2. Name the method.

    The name is used as the name of the item in the Scripts menu. For example, a method called insertHeader will create a menu item called InsertHeader.

    To create a submenu with several items, create a method for each item where the first part of the name is the submenu name, for example.

    void sendTo_file(Editor editor)

    void sendTo_mailRecipient(Editor editor)

    void sendTo_printer(Editor editor)

    Custom item in the Scripts menu

  3. Add the editor object as a parameter.

  4. Write the X++ code to perform the desired task, for example.

    void sendTo_mailRecipient(Editor editor)
         SysINetMail mail = new SysINetMail();

See also

Editor Scripts

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