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:
Add a new method to the EditorScripts class.
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)
Add the editor object as a parameter.
Write the X++ code to perform the desired task, for example.
void sendTo_mailRecipient(Editor editor)
{
SysINetMail mail = new SysINetMail();
;
mail.sendMail(
'',
e.path(),
EditorScripts::getSelectedText(e),
true);
}
See also
Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.