September 07, 2013

Method Types in Dynamics AX Classes


Method Types in Dynamics AX Classes

There are many different types of methods. Some of the more common types are
1. Static Methods
2. Main Method
3. Display Methods
4. Accessor Methods

1. Static Methods

Static methods are attached to a class. However, they do not need that class to be instantiated to execute that method. They are not within the scope of the class, so any class variables are not available in a static method.
Static methods are declared static by using the Static method modifier.
Static methods are called using the class name followed by two colons (::) and then the methods name.
The following example shows a static method declaration, and a call to that static method.

static public void myStaticMethod()
{
}
myClass::myStaticMethod()

2. Main Method

The main method is a static method that can be used to call a constuctor. It is special because its name is required to be "main". It is used by the system when the class is run directly from a menu item and it takes a parameter of type args. 
Args is a class that is used to pass parameters between objects, for instance, various parameters can be set on the properties on a menu item. When the menu item calls a class, the args class containing those property values is passed to the main method using the args parameter.

3. Display Methods

Display methods are used on forms. They are commonly created on the table, and can also be defined on the form. Display methods return a value that is displayed on the form or report. They are often used to display a calculation, or to look up a single field from another table. 
The following example shows how to display the item name on a form that displays data from a table containing the item id.

// BP Deviation documented
display itemName itemName()
{
inventTable inventTable
select name from inventTable
where inventTable.itemId == this.itemId;
return inventTable.name;
}

The first line in this code is a comment to the compiler indicating that a Best
Practice deviation is considered and evaluated as reasonable. The deviation is
because a display method is able to return any data from any table or field in the system, and so the security implications should be considered.

4. Accessor Methods

Accessor methods enable other elements to set or get the values of variables in a class and it is common that they do both. The following example accepts a value as a parameter, sets a class variable to this value and then returns the value. The parameter has a default value set to the class variable value, so if the method is called without a parameter, it returns the value of the class variable. If it is called with a value in the parameter, then the
class variable is set to this value.

public str myName(str _myName = myName)
{
myName = _myName;
return myName;
}

-Harry

Axapta Application file extensions

Dynamics Ax Application file extensions

In Axapta we found a lot of file extensions are used. Each and every extension have a logical name, so you can easily identify their purpose. The extensions have 3 characters.

Most of these files are located in the application folder (AX 2009):
C:\Program Files\Microsoft Dynamics AX\50\Application\Appl\[your_application]




The first character indicates the owner of the file:


a: application
k: kernel

The second character indicates the content of the file:
l: label
o: object
t: text
d: developer documentation
h: help

And the third character indicates the type of file:
d: data
i: index
c: cache
t: temporary


Using this logic, we can easily name all file extensions, and understand their purpose.

In the application folder:
ALD : Application Label Data files
These files contain the labels and label comments for a specific language of a label file.


ALC : Application Label Cache files
These files contain the application label cache. These files can be deleted when the AOS is stopped.


ALI : Application Label Index files
The .ali files contain an index to the .ald files. These files can be deleted when the AOS is stopped.


ALT : Application Label Temporary files
These files contain new labels before they are committed to the .ald file.


AOI : Application Object Index file
The AOI file contains an index to the AOD files. You can delete this file when the AOS is stopped. Be sure to delete this when you have copied layers from one AX installation to an other.


ADD : Application Developer Documentation Data files
These files contain the documentation that is found under the Application Developer Documentation node. These files are localized, just like label files.


ADI : Application Developer Documentation Index files
This is the index to the ADD file.


AHD : Application Help Data files
The AHD file contains the documentation aimed at the end user. In the AOT, this is found in the “Application Documentation” node
.

AHI : Application Help Index files
This is the index to the AHD file.


AOD : Application Object Data file
This is the ‘AX layer file’, each of these files represents one layer.


KHD : Kernel Help Documentation files
These files contain the kernel help documentation you can find in the AOT in the tree node System Documentation.


KHI : Kernel Help Index files
The KHI file is the index to the Kernel Help file.


Located in Server/bin:

KTD extension: Kernel Text Data file
This file contains system text strings. These are used in the interface of AX and for system messages.


KTI extension: Kernel Text Index file
This is the index to the KTD file.


-Harry