About labels

  • July 31, 2009
  • 0 Comments

In Ax there is a class called SysLabel. When you want to expiriment with labels, this is the place to be.
Some examples:

You want to find a label in a specific language. There are a few ways to do this, for you to chos witch fits best.

1
2
3
4
5
// Method 1:
info(Syslabel::labelId2String(literalstr("@SYS115063"), "en-us"));
 
//Method2:
info(Syslabel::getLabelInstance("nl-be").extractString("@SYS115063"));

Or you can do it the long way

1
2
3
4
// Method 3:
SysLabel sysLabel = new SysLabel('en-us');
;
info(sysLabel.extractString('@SYS115063'));

A other cool thing you can do with labels is when you have the label in language ‘X’, lookup the corresponding labelId (@SYS…).

1
info(Syslabel::getLabelInstance("en-us").searchFirst("Microsoft Dynamics Ax"));

When you had a labelId and you want to verify if it is really a label, there is the static method isLabel.

1
2
3
4
if (SysLabel::isLabelId(literalstr("@SYS115063")))
{
    info("ok");
}

And finally when you want to modify a label from code, this is possible by modifying a SysLabel-instance.

1
Syslabel::getLabelInstance("en-us").modify(literalstr("@JDN1"), "new label value");

Note: this last change wil automaticly leave a trace in the label log.

So, knowing all this you can create your won improved label-editor. 😉