Wednesday, November 25, 2009

Kernel functions exposed through BC.NET

BC.NET is a great feature of Dynamics AX. It allows to access the AX application from any external application that supports .NET, and provides a rather rich functionality out of the box.
But one feature that is missing in BC.NET is the ability to call AX kernel functions, like fieldId2Name, num2str, decRound, etc.

I needed to use these functions in my code recently, and in order to access them, I created a class in X++, that simply wraps the useful functions in static methods, kinda like the ones that exist in class Global.

Download Class_KernelFunctions.xpo

You need to import it into AX before using, of course. This can be automated, if you don't want to include this XPO as part of the package you deliver to your customers.

Now you can call it through the Business Connector the following way:

Axapta ax = new Axapta();
ax.Logon("ext", null, "localhost", null);
// num2str(123.45, -1, 2, 1, 1);
Convert.ToDouble(ax.CallStaticClassMethod("KernelFunctions", "num2str", 123.45m, -1, 2, 1, 1));

Tuesday, November 24, 2009

SysCompilerTarget - compiling X++ code without showing the compilation window

I have been posed with a question about how to avoid showing the compilation window during compilation of some X++ code (When doing compilation from code, naturally).

So I decided to post a possible solution for this question, re-using one of my previous posts about ClassBuild class.

Basically, AOTcompile method on TreeNode class supports an optional flag, controlling the compilation output:
An integer that indicates whether output should be sent to the message box. If the value 1 is passed, no output is sent to the message box. The default value is 0. This parameter is optional.

So all we need to do now is change the compilation output target to Message Window. Looking at the SysCompilerSetup form code, it's rather easy to come up with the following code:

static void SysCompilerTargetExample(Args _args)
ClassBuild classBuild;
DictClass dictClass;
SysCompilerTarget targetOrig;
// Setting Compilation Target = Message Window
targetOrig = SysUserInfo::compilerTarget();

// Building the class with 1 method
classBuild = new ClassBuild("TRN_ClassBuild", false);
classBuild.addMethod("test", 'void test()\n{\n}');
classBuild.addSourceToMethod("test", @"
info('We created a Class and can call its methods');");

// The actual compilation. Note the _flag argument == 1

// Call the class method to show that we are done and the code is compiled
dictClass = new DictClass(className2Id(;
dictClass.callObject('test', dictClass.makeObject());

// Restoring Compilation Target to its original value

Don't forget to restore the original settings after the compilation is complete, as shown above.

Friday, November 6, 2009

How to quickly set up Application Integration Framework (AIF) for testing Axd documents

Purpose of this post
Part of the test effort on our team at MDCC goes for verifying the Axd documents shipped with the Dynamics AX application.

As many people find it hard to setup AIF, I have tried to help them by creating an automated way of doing the initial setup, which can be used for testing the documents using a 1-box setup and FileSystem transport adapter.

Download link
From the following link, you will be able to download an X++ class that initializes all the entities required for AIF to work, like the endpoints, transport adapters and channels, services, their actions and action policies.
Note, that since I am working on the Inventory team, I am filtering out the services accordingly. You can easily extend/modify this to suite your specific needs by changing the filter or adding new ones in classDeclaration and method main

Download xpo

Example from the standard application
To give a specific example, I encourage you to try sending a selected item electronically in form of an XML file right after executing the job.
To do that, navigate to Inventory Management\Common forms\Item details and press Send electronically button. Fill in the values for endpoint, filter on a specific item(s), and press OK.

Your screen should look similar to this:

Processing the document
The document is successfully placed into the queue for processing and sending through the gateway. If you have a batch job for processing AIF services up and running, you will soon see a file in the outbound files folder setup on the outbound channel.
If you would like to learn, how to set up the batch jobs for this, follow the below link: Start and stop the asynchronous AIF services

In order to avoid having to set the batch jobs up, I have added 2 extra methods to the class for starting the processing of inbound and outbound messages.

public static void ProcessOutboundDocuments()
new AifOutboundProcessingService().run();
new AifGatewaySendService().run();
public static void ProcessInboundDocuments()
new AifGatewayReceiveService().run();
new AifInboundProcessingService().run();

Just call the DEV_AifInitialSetup::ProcessOutboundDocuments method from a job, and the document will be automatically processed and sent on its way to the outbound documents folder.

The resulting XML file for the item should look similar to the following:

Wednesday, November 4, 2009

Microsoft Layoff 2009 Completes Last Milestone and Ships!

With today's 800 Microsoft layoffs, Microsoft Layoff 2009 has reached its final milestone and shipped, exceeded expectations of 5,000 with 5,800 reduced positions.

Err... yay?

Last week during the Town Hall Mr. Ballmer confirmed there would be one more iteration on the layoffs. And after that? Who knows. More to come? Maybe. Booga booga!

You know, we have people working for Microsoft (or, at least did, I don't know, maybe no longer) responsible for driving executive leadership education and growth at Microsoft. This is their friggin' job. Develop Microsoft Leadership at the executive and L68+ levels. So, has anyone hemmed and hawed in-front of Mr. Ballmer and mentioned that this nickel and diming layoff approach is at the worst case end of the layoff management scale?

The looming threat of continuing RIFs and layoffs indicates that Microsoft is just too big for its leadership. It is beyond their capabilities to wrap their minds around everything Microsoft is doing. It has gotten away from them. What needs to go? Hell, I don't know even what all these people do, and you want to decide who stays and goes?


Cut deep. Cut once. Get on with it and say, "We're done. We have aligned our company to be efficient and effective within this new global economic climate and are ready to focus on returning to profits and market share growth."


Coverage I've noticed today on the outside:

On Don Dodge:

And, bummers for me given that she interviewed me for Microspotting, Ms. Ariel Stallings tweet about being caught up in this layoff round.

Coverage from the inside? No email. Quiet. Quite dysfunctional. There was something linked off of the MSW site and it also had a FAQ document that had to be one of the worse FAQs I've ever read. There is an "A" portion to an FAQ and in this case some of the questions were great but the answers looked like they were generated from some sort of English obfuscation Perl script 3rd place prize winner.

So, I'm going through about sixty comments now on the older post. I think it was necessary for Microsoft to have layoffs due to the mismanaged growth and lack of focus and direction our Senior Leadership Team has given us. But it should have been twice as much, done all at once. Now we dither.

Were you affected by the layoff or know someone who was? I'd be interested in knowing which groups and organizations are affected.

-- Comments