Thursday, March 26, 2015

Variable declaration

Variable declaration

Variables must be declared first in the method. We can’t declare the variable inside the X++ statements. In other languages like .net, VB we can declare wherever you want. In AX 2009 we should use semicolon (;) to separate the declaration part and X++ statements like the below code.

AX 2009 variable declaration

int a;
;
a = 5;

But, in ax 2012 semicolon is not necessary (optional). We can assign values in the declaration part.
int a =5;

Variable name

In X++, variable names are not case sensitive. As per the naming convention standard, the first character of the variable name should be small letter. For example:
PurchLine purchLine

Data types

Primitive and composite data types are supported in X++. We can use EDT, table name, class name as data types. For example:
Name                    firstName, lastName;
PurchLIne            purchLine;
Access                  accessObject = new Access();

Multiple variable declaration

X++ allows you to add multiple variable declaration in the same declaration statement. For example:
int i,j;

real a = 5, b=3;

Sunday, March 15, 2015

Labels

What is label?

Labels in AX, is used to assign text to the objects ex. table fields. We can avoid to create duplicate text in label before create a new label by find the label in the label editor.
We should use labels for user interface text in forms and reports.

Label editor:

Label editor is an editor used to create, find, update and delete labels.
Open label editor:
In development workspace, Tools - > Label -> Label Editor


Create a label:

Open the label editor, click the new button and enter the text and description. Once you saved this label, the label id will create automatically the label id format will like @TES123. We can assign this label id to table field.


Assign label to the table fields:

Select the table field and go the properties window and select the label property, click the … button and enter the text, click the find button, the labels will come if the label already exist otherwise we need to create a new label.
If you know the label id then, we can directly enter the label id in the label property of the table field.




Use labels in the X++ code:

We can also use the labels in the x++ code.
For example: info('@SYS80122');

Use labels in the SSRS report:

We can use the AX labels in the AX SSRS report design. So, once we change label text in the AX label editor, it will automatically reflect in the SSRS report. Mention the label in the object expressions. For example: Lables!@SYS80122

Labels file:

The labels are stored in the label file. The label file is based on the language.
To create label files, Click Tools -> Wizards -> Label File Wizard
We can find the labels in the AOT -> Label files.

We can export and import this label files (.ald) to move the objects from one environment to another environment like development to production.