Pages

Friday, February 10, 2012

Inserting code snippets in the AX 2012 X++ editor

In the AX 2012 X++ you can quickly insert fragments of code to avoid tedious typing, such as typing for a loop.

To insert a snippet, you must enter the snippets alias (which is usually the first symbol of the code), and press tab. For example, typing switch followed by tab, gives you this snippet:
switch ()
{
    case :
        break;

    case :
        break;
}

I don't have a clear picture of all the available aliases, but these work:
  • switch
  • for
  • do
  • while
  • try
In the regular Visual Studio editor you can add your own code snippets. I haven't figured out yet, if this is also possible for the X++ editor.

UPDATE: Brandon, a fellow blogger, wrote a great blog post about these scripts: AX 2012 - xppSource Exposed: Inserting code snippets

Preventing client crashes when applying new event handlers

Almost every time I create a new pre- or post-event handler and try to use use it immediately on a new Event Handler Subscription, the AX client crashes.

You can prevent these crashes by saving the event handler class and restoring it, before addressing it on a new Event Handler Subscription. Restore is placed on right click / Restore.

Thursday, February 2, 2012

"Find as you type" in the AX 2012 X++ editor

As you may know the new X++ editor in AX 2012, is actually the Visual Studio editor.

One of the sweet things that gives us, is the ability to do "Find as you type" searches in the code.

Press CTRL + I once, and set of binoculars pops up. Now start typing, and you can see how the editor starts to find matching values in your code. If you want to stop the typing, and just find the next instance of the same text, just press CTRL + I again.

To search upwards in the code, press CTRL + Shift + I.