Thursday, September 29, 2016

Setup a keyboard shortcut on the WMS mobile device portal

You can setup keyboard shortcuts for the mobile device portal without any code changes at all. Here is in short what you need to do.

You need to know two things before you can setup the shortcut:

  1. The HTML id of the button type to create the shortcut for.
  2. The JavaScript keyboard code for the key you want to use.
You find the HTML id of the button type by looking at the HTML source behind it. In Internet Explorer you right click a button of the type and select "Inspect element":

Then you can find the HTML id here:

The JavaScript keyboard code you can find from this menu item (sorry, the screenshot is in Danish, but it should say something like "Show codes for keyboard short cuts"):

When you have clicked the menu item, just hit the key you want to use and it will show the keyboard code:

Here I have hit the escape key and got code 27 for that.

Now you need to decide how to show what the keyboard shortcut is shown as. That is added to text of the button. In this case I'll show it as "ESC".

To enable the escape button  for "Cancel", I can enter the following setup in "Work user mobile display settings":
So this is "HTML id"("text to show in the button")="keyboard code"

And it'll look like this:

Here is a good article from Microsoft explaining the setup:

Friday, September 2, 2016

The Microsoft Dynamics AX Help Wiki is getting a lot of good content these days

The last few days and weeks a lot of good documentation has been added to the Wiki. If you want to follow new articles you should subscribe to the RSS feed.

And by the way, a lot of the X++ documentation also applies to older versions than AX7.

Friday, August 12, 2016

Don't change the name of a Form instance in AX 7

In AX 2012 you could do something like this, where you change the name of a Form instance:

form = new Form(formstr(MyPrettyForm));"AnotherNameToConfuseEverybody);

args = new Args();

formRun = classfactory.formRunClass(args);

In AX 7 changing the name seems to confuse AX to a sense where it can't figure out to actually run eventual code in (at least) the init and run methods of the form.

For many reasons I think it is a poor idea to change the name of a form instance, now there is also a technical reason not do it.

Wednesday, August 10, 2016

Public members vs. Parm methods on classes extending SysAttribute in AX 7

I thought I did the right thing when I changed attribute classes that I moved into AX 7 from AX 2012, so they had public members instead of Parm methods.

Well, don't do that. As it turns out the attribute framework is looking for the Parm methods when trying to apply the member values. If you don't have them, the values are not being set.

Hopefully this information can save you an hour or so of tedious debugging.

Wednesday, July 20, 2016

Moving label files between models in AX7

When you need to move label files between models in AX 7, there are a couple of thing to remember.

  • A label file consists of several files.
    Under \AxLabelFile there is an XML file for each language with some metadata about the label files.
    And then again under \LabelResources you'll find the actual label files for each language.
  • In the XML files with the metadata about the labels your need to modify the RelativeUriInModelStore property to reflect the new location.
  • You should move the above files from VSTS, so you keep version history of earlier changes.
  • If you did an earlier build, you must manually remove the compiled dll's for earlier compiled labels files. You'll find these in the Resources folder for the model you moved the files from. There is a dll directly in the folder, and one in the subfolder for each language. If you don't remove the dll's, AX might keep using the old and wrong version.  

You might want to move the label files from under ApplicationSuite, where the LCS upgrade tool puts your custom label files, into a new extension model.

Thursday, June 23, 2016

One of those functions...

Now and then you come across AX functions you haven't heard about or that you have never really used. The lack of usage is often linked to the lack of documentation, but that's another story.

Today I came across the formattedStr2Num function. It is able to take a formatted string with some arithmetic and do a calculation of the expression. Something I have often seen developers write code to pass through the compiler and run the compiled code to do.

Here is a small example of how to use it:

static void formattedStr2NumDemo(Args _args)
    str s = "(8 + 2) / 2 * 4";
    info(strFmt("%1", formattedStr2num(s)));

The function actually also pass the expression through the compiler, but in a controlled way so you can't just run any old arbitrary (dangerous) code through it.

If you combine this with a dynamic strFmt call, you have yourself a small expression calculation engine.

The timing for me to figure this out is awful, since the function is deprecated in AX 7. From AX 7 you could instead use something like ADO.NET's expressions parser in DataTable.Compute.

Thanks to Marco Scotoni, Johan van Veldhuizen and of course Peter Villadsen for being smarter than me and learning me this today through the Yammer group we share membership of. And I hope I wasn't the last AX developer on earth to learn about this function.