Microsoft Dynamics Ax developer's blog

Monday, November 01, 2010

the future of F#

The very interesting session from PDC10 related to the future of F# - Microsoft functional-object-imperative variance of OCAML.

They are extending application with "type providers", which allow to extend static type system of F# with dynamically generated types withoun explicit code generation - by implementation of a very simple interface.

I think it can be useful techique to implement business platforms such as LightSwitch (when it come to C#) - LightSwitch authors can just implement type provider for entities and do not generate very much intermediate code.

PS. I think there is aplso enteresting how easy Don manipulates various data in F# interactive

Friday, October 29, 2010

How to open a form in a running Ax client from an external application

Some times ago someone asks me if it possible to open form in running Dynamics Ax application with external code. He don’t want to use AxPath for some reason.
I recalled there is a similar thing in Ax (since version 4.0) – when you receive an event alert message you can click an a link and go to the corresponding alert.
The idea was to reuse alert handling code as much as possible. And I achieved that without changing Ax code at all.
How alert links work?
1. When you start Ax32.exe, it runs the EventDrillDownPoller class, that creates a named pipe with name like “Dynamics\Event\0S-1-5-5-0-686394” (you can use pipelist utility from the SysInternals suite to obtain exact name of your named pipe) where
  • Dynamics\Event\ – is a constant prefix
  • 0 – is a value from the “Drill Down target” field in the “Basic\Setup\Alert\Alert parameters” form
  • S-1-5-5-0-686394 – is a user system session ID
and then time is being initialized, handler of the timer polls named pipe and executes SysStartupCmd descendant when message received.
You can look at \Classes\EventDrillDownPoller\scheduledPoll code to see the details.
2. When you click on the link in e-mail, axhlink.exe protocol handler is executed, it parses url and connects the named pipe obtaining it’s name using “Drill down target” from url and current session id. Then it writes a command to the named pipe.
3. When timeout handler (which was subscribed to the times in 1.) detects there is a new message in the pipe, it just runs a SysStartupCmd and then recreates a named pipe (see \Classes\EventDrillDownPoller\scheduledPoll – unfortunately it uses the current company to detect a drill down target, so if you have different values of the field in different companies ad user changes the current company, you can see it recreating a named pipe with a different name – it can cause mistakes)
So the task is pretty simple
  • Create an autorun startup command configuration file
  • Connect to the named pipe using session id and provided drill down target
  • Write a zero terminated Unicode string with a startup command to the pipe
You can download code example here

Contents:
  • C# sources of sending a message  (command line utility that takes startup command and drop target ID)
  • XML file example
  • XPO with modification for autorun startup command code, adding a parameter to navigate to a specific record (that was additional requirement – it takes table and recID attributes)

Tuesday, August 24, 2010

Seattle

If you live in Seattle or know that area well, could you, please mail me mbelugin@live.ru

Saturday, June 05, 2010

Data/Control flow

I draw Data-Control flow diagrams for better understanding of some process in code. It looks something like that:

dcfd

Legend:

  • ---> – control flow
  • ==> data flow
  • Ellipsis – method
  • Rectangle – data storage
  • Rectangle with rounded corners – class
  • If ellipsis is located on the border of a class – it is a public method

Such diagrams help me later to understand place of some piece of code in some process in system.

It is critical not to draw unnecessary details on a diagram and stay focused on the current task, in other case a diagram will be unreadable. For example diagram in this post is near the edge of readability – lots of intersections are signs of it.

Tuesday, February 23, 2010

Book review: “Microsoft Dynamics AX 2009 Programming: Getting Started”





See the book description on the publisher's site: "Microsoft Dynamics AX 2009 Programming: Getting Started"





When I've received the book, I first thought about beginning of my experience with Ax: in 2003 I worked with BAAN and planned to become a developer for Ax 3. I have decompiled developer's guide and best practice chm, downloaded it to my Sony SL10 and read it for month or two in the Moscow subway during daily commute. I can recall some difficulties I've met and I expect from every book for beginners to go beyond Dev Guide and BP describing these particular areas.



I think the main two topics to learn for every Ax developer are:

  • Dynamics Ax development platform
  • X++ code that implements business logic

Historically, platform was the more clear area docs, but has some dark corners, but business logic was less documented and the knowledge transferred mostly from the code itself, more experienced colleagues, and online communities.

So I tried to search for following topics:

  1. Links to external information sources such as MSDN, Partner Source, internet communities
  2. Data access (Ax have a very specific SQL implementation)
  3. Forms layout
  4. Business logic patterns
  5. Tools and techniques to extract information from X++ code

BTW one of the book reviewers, Harish Mohanbabu, is known by his blog and free Ax tools.

First, the book contains list of online resources links related to Ax, such as blogs, axaptapedia, official sites, so on. The only thing I wish to add it to explain what partner source and what customer source are, and how to get access – it is very frequent question from newbies.

Database manipulation is described in several chapters, the description is easy to understand, full of example screenshots and can be useful for new developers, but I missed description of union joins (which is new to Ax2009 and I haven't seen much usage in the existing X++ code)

Forms-related information is shown mostly by example; you should refer to developer's guide for more detail. I think, it should be better to provide more information on different form layout templates, and some existing form patterns. Anyway, I think, a novice programmer can learn basic form structure prom the chapter and can use some more advanced techniques such as splitters and edit methods.




There are some chapters related to most frequently used business modules, such as inventory, ledger and accounts receivable/payable, each starting with small entity-relationship diagram of basic tables with examples of using Ledger posting framework, adding new dimension, etc..

The topic about tools contains example of usage of cross reference with screenshots, but profiler and trace parser have not been mentioned.

So these were topics that I was interested in due to I remember I had problems with, when I started to learn Ax.

In addition there is lots of information related to:

  • Other platform areas (such as X++ basics, AOT nodes, architecture, File export and import), which have not caused learning problems for me but maybe can cause to other novice developers.
  • Parts of platform I have not used (Application Integration Framework , Enterprise Portal, Webservices) - so I cannot say anything about them

The book contains an example of car rental module (with full sources in xpo's). Chapters of the book describe corresponding pieces of example code and I think it's a good manner to write books for developer.

I definitely recommend the book for novice developers as a good addition to manuals that go with the product and msdn.