10 Sep. 2011

Microsoft Dynamics AX 2012 White Paper: Developing Solutions in a Shared AOS Development Environment

This white paper outlines the development guidelines for Dynamics AX 2012 and how to setup and use version control with Team Foundation Server or MorphX VCS. The document provides guidance for developing solutions when multiple development clients are connected to a single shared AOS. With AX 2012 we have new additions to the development mix of tools and techniques like: Visual Studio clients, CIL run-time, SSRS Report Data Provider classes, etc.

I cannot stress enough on how important version control really is, especially in development environments with many programmers. Take a look at it:

Microsoft Dynamics AX 2012 White Paper: Developing Solutions in a Shared AOS Development Environment

 

9 Sep. 2011

Slipstream installation for Dynamics AX 2012

Slipstream installation is the process of installing of Dynamics AX 2012 + all the latest Cumulative Update at one go. With the previous versions of AX it was not recommended to do this. We had to install the vanilla AX from the installation image and then apply all the service packs and roll-ups. Now with AX 2012 you can extract the contents of the self-extracting file of the CU installer to the Update folder of the AX installer. Now when you start the AX installer all the updates will be applied automatically.

Here is the original article at EMEADAXSupport:

How can I slipstream Cumulative Updates for AX 2012 as part of a new installation




8 Sep. 2011

Date Effective tables with ValidTimeState and Dynamics AX 2012

You may have noticed the new ValidTimeStateFieldType property on tables in AX 2012. The enum values are None, Date and UtcDateTime. This is part of the new & cool Date Effective Table framework that comes with Dynamics AX 2012. The idea is to minimize the effort for managing period gaps, overlapping periods, period validation, etc. So, let's get down to how it works.
  • We create new table called DEV_ValidTimeState and we add new field named ItemId
  • We set the ValidTimeStateFieldType table property to UtcDateTime. At this point AX automatically creates 2 new fields: ValidFrom and ValidTo.   
     
  • Now we need to create new unique index, which should include the fields ItemId, ValidFrom, and ValidTo
  • We set the following index properties  
    • AllowDuplicates to No.
    • Alternate Key to Yes.
    • ValidTimeStateKey to Yes.
    • ValidTimeStateMode to Gap
  • Now let's insert some records.
  • static void createValidTimeState(Args _args)
    {
        DEV_ValidTimeState table;
        ;
    
        delete_from table;
    
        table.clear();
        table.validTimeStateUpdateMode(ValidTimeStateUpdate::CreateNewTimePeriod);
    
        table.ValidFrom = DateTimeUtil::newDateTime(1\1\2012, 0);
        table.ValidTo = DateTimeUtil::maxValue();
        table.ItemId = '1000';
    
        table.insert();
    
        table.clear();
        table.validTimeStateUpdateMode(ValidTimeStateUpdate::CreateNewTimePeriod);
    
        table.ValidFrom = DateTimeUtil::newDateTime(6\6\2012, 0);
        table.ValidTo = DateTimeUtil::maxValue();
        table.ItemId = '1001';
    
        table.insert();
    }
  • Here is how to select and update records from the table. Please note the use of the validTimeState keyword with select statements and there is a new xRecord method called validTimeStateUpdateMode.
  • static void updateValidTimeState(Args _args)
    {
        DEV_ValidTimeState table;
        utcDateTime fromDateTime, toDateTime;
        ;
    
        fromDateTime = DateTimeUtil::newDateTime(3\3\2012, 0);
        toDateTime   = DateTimeUtil::maxValue();
    
    
        select validTimeState(fromDateTime) table;
    
        info(table.ItemId);
    
        select validTimeState(fromDateTime) * from table;
    
        info(table.ItemId);
    
        select validTimeState(fromDateTime) ItemId from table;
    
        info(table.ItemId);
    
        select validTimeState(fromDateTime, toDateTime) ItemId from table;
    
        info(table.ItemId);
    
        ttsBegin;
    
        while select forUpdate validTimeState(fromDateTime) table
        {
            table.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
            table.ItemId = '1002';
            table.update();
    
        }
    
        ttsCommit;
    }
    
  • The query framework was updated to support the new Time Effectiveness feature. Here is the code sample:
  • static void queryValidTimeState(Args _args)
    {
        DEV_ValidTimeState      table;
        utcDateTime             fromDateTime, toDateTime;       
        Query                   q;
        QueryRun                qr;   
        QueryBuildDataSource    qbds;
        ;
    
        fromDateTime = DateTimeUtil::newDateTime(3\3\2012, 0);
        toDateTime   = DateTimeUtil::maxValue();
    
        
        q = new Query();    
        
        qbds = q.addDataSource(tableNum(DEV_ValidTimeState));
        
        q.validTimeStateAsOfDateTime(fromDateTime);
        
        qr = new QueryRun(q);
        
        while(qr.next())
        {
            table = qr.get(tableNum(DEV_ValidTimeState));
            info(table.ItemId);
        } 
    } 


To sum up, in AX 2012 we have new feature that allows us to manage the time periods associated with an entity. We get all the benefits of validation and period gaps management for free (that's sweet). In order to support the new feature some changes have been introduced:
  • All tables now have new property called ValidTimeStateFieldType
  • Table indexes now have new properties
    • ValidTimeStateMode 
    • ValidTimeStateKey
    •  Alternate Key should be set to Yes
  • The kernel class xRecord and all tables now have the validTimeStateUpdateMode method. 
  • There is new system enum ValidTimeStateUpdate with the following values:
    • Correction – the ValidFrom or ValidTo values of existing rows must be modified to keep the date effective data valid after the update completes. 
    •  CreateNewTimePeriod – a new record is inserted into the table to maintain the validity of the date effective data after the update completes. 
    • EffectiveBased – forces the update process to switch to CreateNewTimePeriod for each row that spans the current date-time; otherwise to switch to Correction
  • The kernel class Query now has 4 new methods:

6 Sep. 2011

Dynamics AX Books



Dynamics AX: A Guide to Microsoft Axapta


This book is classic. It gives an overview of the product and its basic designs and frameworks.



Using Microsoft Dynamics AX 2009

This is excellent and up-to-date book on Dynamics AX. Highly recommended.




Managing Your Supply Chain using Microsoft Dynamics AX 2009

It's all about SCM. The book by manufacturing guru Scott Hamilton studies many different scenarios.




Technical books:

MORPHX IT, An introduction to Axapta X++ and the MorphX Development Suite

This is one of the first books on AX and X++ development. Highly recommended.



Inside Microsoft Dynamics® AX 2009

This is a must-read for every technical person starting up with X++ Dynamics AX as platform for development. After the release of this book for version 2009 Microsoft made available for free the book for version 4.0. You can download the pdf from here.




Microsoft Dynamics AX 2009 Programming: Getting Started

A well-written and gentle introduction to the world of X++ and Dynamics AX. Obviously if you have many years of experience with AX you will find less value in reading this book.




Microsoft Dynamics AX 2009 Development Cookbook

As the name suggests this book contains some recipes and boilerplate code to be adapted to your custom needs. If you struggle for hours to do something simple, well this is the book for you.




Quality Assurance for Dynamics AX-Based ERP Solutions: Verifying Dynamics AX customization to the Microsoft IBI Standards


An excellent book on quality assurance and best practices. Everybody should read this.



 Microsoft Dynamics AX 2009 Administration

With every new release the installation process of AX gets even more involved than the previous version. This book is good introduction to the most common configurations. If you are faced with a very complex scenario it's very likely that you wont find all the answers in this book.




31 Jul. 2011

Dynamics AX 2012 Table inheritance & polymorphism

In the version pre-AX 2012 all tables in the AOT extended from the Common table so that all tables had the methods from the xRecord class and you could use an object of type Common as a polymorphic reference to any table in the AOT. All this still applies to AX 2012 but the notion of table inheritance now different. Here is the list of the new features in AX 2012:
  1. Field inheritance
  2. Method inheritance
  3. Method polymorphism
  4. Casting
  5. CUD support for the entire graph of tables in the hierarchy
The first 3 points are pretty self-explanatory, but things start to get interesting with point 4. Casting. Consider the following code fragment:

    DirPartyTable   dirPartyTable;
    DirPerson       dirPerson;
    
    dirPartyTable = dirPartyTable::find('7');
    
    info(DirPartyTable.Name);
    
    if(dirPartyTable is DirPerson)
    {        
        DirPerson = dirPartyTable as DirPerson;
        info(enum2str(dirPerson.BirthMonth));        
    }        

Note how the record is casted from type dirPartyTable to type DirPerson. Dynamics AX 2012 introduces 2 new X++ operators is and as. Here the is operator checks if the dirPartyTable object can be downcasted to its subtype dirPerson. The as operator is used to actually downcast the dirPartyTable object to the dirPerson subtype. So far this is similar to what we could achieve (with slightly more X++ code) with the previous versions of AX, but this is not just syntax-sugar. In AX 2012 when you select a record with select * from this means select all fields form all parent and child tables and this is fundamentally different from the previous versions of AX.

Now, let's consider point 5. CUD support for the entire graph of tables in the hierarchy

Obviously CUD here stands for Create, Update, and Delete and "support for the entire graph of tables in the hierarchy" means that all CUD operations are cascaded to all parent and child tables in inheritance hierarchy. For example in AX 2012 when you create a record in a child table the same record will be created in the parent table as well. When you delete a record from table, belonging to a table inheritance tree, the same record will be deleted from all child and parent tables in inheritance hierarchy. It is important to note that if a the cascade operation on a child or parent table fails then the entire transaction will be aborted.




30 Jul. 2011

Dynamics AX 2012 and BizTalk 2010 white papper

As you may know the BizTalk AIF adapter was removed in AX 2012.
Microsoft just published a white paper about the integration between AX 2012 and BizTalk 2010

Here is the link:
Using Microsoft BizTalk Server 2010 to Exchange Documents with Microsoft Dynamics AX

29 Jul. 2011

Form control type at run-time

This shows how to get the type of a form control at run-time. The code iterates through the controls in a field group and checks each control for it's type.

    FormControl fc;
    int         i;

    // ...
   
    for(i=1; i <= FieldGroupName.controlCount(); i++)
    {
        fc = FieldGroupName.controlNum(i);
        if(SysDictClass::is(fc, classNum(FormStringControl)))
        {
            info(strFmt("%1 %2", fc.name(), fc.type()));
        }
    }
If you do this in Dynamics AX 2012 you will get the following warning:

The SysDictClass::is method is obsolete. Use the IS operator instead.


The new syntax is:
if(fc is FormStringControl)

Looks better, don't you think?

28 Jul. 2011

Import customer address in the Global Address Book

In AX 2012 the GAB (Global Address Book) has gone through some serious changes and now the address information for the customers and vendors is kept in the LogisticsPostalAddress,and LogisticsPostalAddressExt tables. Additional information is maintained in the LogisticsAddress* tables.

This is the simplest possible example of how to create new customer and populate the customer's address information in AX 2012. Note that you may have to modify this code in order to handle the creation of records in the LogisticsAddress* tables.

        CustTable                       custTable;
        AccountNum                      accountNum = 'ABC-123';
        CustGroupId                     custGroupId = '10';
        Name                            name = 'ABC';
        
        DirParty                        dirParty;
        DirPartyPostalAddressView       dirPartyPostalAddressView;


        ttsBegin;

        custTable.clear();
        custTable.initValue();

        custTable.AccountNum = accountNum;
        custTable.CustGroup = custGroupId;

        custTable.insert(DirPartyType::Organization, name);

        dirParty = DirParty::constructFromCommon(custTable);

        dirPartyPostalAddressView.LocationName = 'ABC-AUTO';
        dirPartyPostalAddressView.City = 'London';
        dirPartyPostalAddressView.Street = 'Dover Street';
        dirPartyPostalAddressView.StreetNumber = '123';
        dirPartyPostalAddressView.CountryRegionId = 'GBR';

        dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);

        ttsCommit;

27 Jul. 2011

Installation warning with AX 2012 and SSRS

While installing the Reporting Services Extensions for the pre-release version of Dynamics AX 2012 the installation process finished with warning and the SSRS reports were not deployed. To deploy the reports I had to run the AxDeployReports.ps1 script located in C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities directory. I order to be able to run the script from the file I had to run PowerShell with administrative privilege and then set the execution policy to bypass.

(click on the screenshot)

26 Jul. 2011

Dynamics AX 2012 is here

Dynamics AX 2012 is the next generation of business software by Microsft. The standard package includes the classic ERP  + CRM + Accounting offering + extended functionality for lean manufacturing, process manufacturing, environmental sustainability dashboard, public sector, etc. The product is localized and translated in more than 40 languages and that makes it suitable for all sorts and sizes of customers all over the world.

Integration and ease of deployment is another the key point. Dynamics AX is offered by the Microsoft's channel of  ISV and VAR partners. Different types of deployments are offered- from on-premise to cloud-computing. AX fits nicely with the rest of the products in the stack: Hyper-V,  SharePoint, Visual Studio, SQL Server (SSRS, SSAS), Project Server, MS Office, Terminal Services, Windows Server AD, etc. and
 makes a perfect match for companies that run on Exchange and Excel (are there any other).

The UI  feels pretty much like Office 2010. End-users will love the way in which the information is organized. If you feel like weightlifting all the power from the previous versions is still present, but the ribbon interface makes things so much easier. In addiction to that the new and enhanced Workflow functionality allows for modeling all sorts of business scenarios with almost no need for programming.

Obviously the MBS division has invested a lot of effort in order to get the job done and
the future looks bright for AX 2012.