Saturday, 29 March 2014

Label IDs in Dynamics AX 2012

 Dynamics AX handles text localization by using a label ID (e.g. @SYS1234) in code and metadata; the real text is looked up then based on user’s language. .NET developers may recall localization resources and satellite assemblies and it’s indeed a very similar principle.
There are few changes in Dynamics AX 2012 regarding labels, mostly because of the movement of application files to database (model store). Labels are now located in AOT (Label Files node) or – from another perspective – in ModelElementLabel table in database.
New label files are still created by Label file Wizard, but the existing ones are imported and exported in AOT, not as before by direct manipulation with .ald files in the application directory.
This alone is a quite confusing change for many people and even more radical changes were made for labels saved in a version control system.
Version control                                                                                                           
If you create a new label, let’s say in the ABC label file, ID of the new label is @ABCx (e.g. @ABC42). It was exactly the same in previous versions too.
But if a version control is active, it’s different.
In case of active version control, a temporary label ID is created at first. It looks somehow like @$AA1 (I think one temporary label file is created for each user-defined permanent file – sequentially from AA to AB, AC etc.).
This temporary ID is replaced by a “normal” ID (i.e. ID corresponding to the label file name) when inserting to the version control. Label ID is replaced also in code and metadata, but only if these objects are checked into version control together with the label file.
What are these temporary IDs good for? If every developer has his own Dynamics AX environment (as recommended), it’s necessary to guarantee that no duplicated IDs are created on different places. It used to be accomplished by Team Server which centrally assigned individual IDs. The current solution doesn’t require any central component for development; each environment assign label IDs by its own. Only when inserting to version control, permanent label IDs are assigned, which is a serial operation without any risk of ID conflict.
Version control in Label editor
Version control commands are accessible from Label editor. They work similarly as for other objects (labels are saved in version control as good old .ald files), just be sure that the right label file (field Label file ID) is selected.

Potential problems
And what if I don’t check in code and labels together?
Let’s show it by an example:
I create two labels and code using them. Notice that they are temporary IDs prefixed by @$:

I insert the code to version control but I forget the label file:

Code is saved to version control without any change and thus using temporary IDs:

Such code obviously won’t work correctly in other AX instances. But if I check in the code again, now with the label file:

temporary IDs are correctly replaced. You also get an infolog message enumerating changed objects:

Another situation arises if you insert labels to version control, but omit some code. All code not included in the check-in stays the same and continue to use temporary IDs. Fortunately, it’s not difficult to find the right permanent label, because the text of the temporary label is changed to contain such information:

However, the fix must be done manually.
No matter how we achieved the goal, now we can run the code with correct labels:

Tuesday, 25 March 2014

Services in Ax

AX 2012 supports the following three kinds of services:

  • Document services are query-based services that can be used to exchange data with external systems by sending and receiving XML documents. These documents represent business entities, such as customers, vendors, or sales orders.
  • Custom services can be used by developers to expose any X++ logic, such as X++ classes and their members, through a service interface.
  • System services are provided by Microsoft Dynamics AX. System services include the Query service, the Metadata service, and the User Session service.
Application Object Server (AOS) is the Windows Communication Foundation (WCF) service host for Microsoft Dynamics AX 2012 services that are exposed to users and applications on an intranet.

  • To consume services over the Internet, you must host services on Internet Information Services (IIS).
  • Services that are hosted on IIS use the WCF message routing service. IIS routes all service requests to AOS.
  • All service requests are processed on AOS, regardless of whether they originate on the Internet or an intranet. AOS then returns a response to the service consumer via IIS.
  • Exchanges that are configured to use Web services are processed synchronously and therefore are not queued.
  • AX deploys the service that is based on Web Services Description Language (WSDL) to a subfolder of the virtual directory that is associated with the Web site that you provide.

Saturday, 1 March 2014

Application Object Tree

                  Application Object Tree

           A full definition of all the element types in Application Object Tree (AOT) can be found in the development training material and developer Help files. Some of the root element types include:
  1. Data Dictionary contains objects that define basic data structure.
  2. Tables contain a group of associated fields. For example the CustTable contains fields relevant to customers. 
  3. Fields on a table contain individual pieces of data. For example, AccountNum contains the customer account number. Fields on a table inherit properties from extended data types.\
  4. Extended data types define a data type and extended properties.There are various basic data types such as a string, integer, date,time and enum. For example, AccountNum is a string extended with properties including a length of 20 characters, left justified and is mandatory.7
  5. Base Enums are enumerated text data types. These are predefined text values that are referenced by an integer value in the database. These are presented to the user as a fixed list of options. For example, Blocked is an enum that gives the user only two options (yes or no) as to whether a customer account is on hold
  6. Classes contain code that is used in the application.
  7. Forms define the layout of all of the forms. Forms are used to view data in the Microsoft Dynamics AX         client.
  8. Visual Studio Projects display any development projects created inVisual Studio
  9. Menus define forms and reports that appear in the menu in the  Microsoft Dynamics AX rich client.