axCoder

Microsoft Dynamics Ax developer's blog

Tuesday, July 12, 2011

XRef–> DGML

image

Just updated my old sample to produce DGML in addition to .DOT, so now you can view cross-references in VS2010 interactively (filter, rearrange so on). For example picture above shows relations of LedgerVoucherObject.check



Download the job from SkyDrive:

Thursday, June 30, 2011

Tabax successor as an illustration of new dev features of Ax 2012


For some reason I've recreated some subset of tabax in Ax2012. I think it can be an illustration of some new Ax2012 features

Since I have no time for debugging learn winapi in deep I decided to use .NET framework as much as possible.

The most magic part of tabax for me is the code that creates and manages tab control to add images and change size of tabs. That code was written by AndyD from AxForum.

but...

now we have a managed host control and can just use any .NET control we want. I decided to use tab control from WPF.

I took Expression Blend and created my own template for control and implemented several templates for tabs (for example, in the screenshot above you can see blue gradient on editor tabs and darker blue gradient on selected tab related to X++ editor).

After that I copied template as avery big string to X++ method and just loaded it in ManagedHost control.

Since Ax 2012 supports events and they are seamlessly integrated with .NET there was no problems with reacting to user actions.

In addition I've found an example of drag-and-drop for tabs and translated it to X++ - now I can reorder tab pages by dragging them.

As a result I have just one form that uses only plain vannila .NET framework (no custom DLLs) all logic is implemented in X++, visual design is stored in 1 big string literal inside X++ form

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.