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();
SysUserInfo::compilerTarget(SysCompilerTarget::MessageWindow);
SysCompilerOutput::setCompilerTarget(SysCompilerTarget::MessageWindow);
SysCompilerOutput::updateParm();

// 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
classBuild.classNode().AOTcompile(1);

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

// Restoring Compilation Target to its original value
SysUserInfo::compilerTarget(targetOrig);
SysCompilerOutput::setCompilerTarget(targetOrig);
SysCompilerOutput::updateParm();
}


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.

Output
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?

Yes.

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."

Done.

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

Monday, October 26, 2009

Mock objects implementation for AX

As you might now, I am working as a Software Development Engineer in Test at Microsoft Development Center in Denmark.

But the only real test framework that comes with AX is the SysTest framework (you can read more about it here).

Below you will find another framework for Dynamics AX, that was written by one of the members on my test team and allows to implement and use mock objects for testing the AX application.

More information and download link

It would be great if you could try it out and provide your feedback here or directly on the author's blog.

Thursday, October 22, 2009

Running a class from AOT or "How to assign a class to an action menu item?"

OK, so this might seem as a very simple question for many of you.

But, in reality, I still now and then meet people who have worked with AX for quite some time, but don't know this very basic concept.

Therefore, I just want to briefly describe it here to refresh everyone's memory

Apart from allowing to run the class from AOT, this will allow to assign it to a menu item (according to Best Practices, it should be a menu item of type Action), and run the class using this menu item.

Below is the correct syntax of the main method:


public static void main(Args _args)
{
//Your code here
}


Please also note, that there is an editor script that contains the template for the main method. You can invoke it from Scripts->template->method->main

Tuesday, October 20, 2009

Windows 7 and a Grab Bag of Microsoftness Before FY10Q1 Results

October 22nd 2009. Windows 7. The circle is now complete.

What is Windows 7? There's a lot that Windows 7 is (oh, it's faster, it has an improved task bar, peeking, snapping, homegroupin', stable drivers and some pretty freaky desktop pictures) but the big thing that it isn't is that Windows 7 is not Vista. It didn't suffer Vista's raging dysfunctional mismanagement and broken windows. It didn't require a reset. Sure, it wasn't perfect and there's a lot of improvements yet to be made in focus and team productivity, but the Windows team delivered. So toot that damn horn, because this here train is arriving on time.

With FY10Q1 announcements coming this week and along with Windows 7, I hope we have a lot of good things to talk about with the analysts. Google and Apple and Yahoo! certainly did. Usually we release our quarterly earnings on the appropriate Thursday afternoon, after closing. It is unfortunately disturbing that we've decided to release our FY10Q1 earning results instead on this Friday morning before trading. I say disturbing only because the last time we did this, a whole bunch of Microsofties were pulled into a layoff. Now... hopefully this earnings report is delayed so that we can have this Thursday the 22nd be all about Windows 7 and not our financials. And I can not imagine that we (and by "we" I mean the Microsoft Senior Leadership Team) would be so dumb as to release our flagship product on a Thursday and turn around and fire a bunch of people the next day.

So, anyway, what's in the mix as the financials come up this week?

Windows 7: check. Thank goodness for SteveSi. I certainly hope he gets paid a lot more than Robbie Bach this year.

Within the Windows 7 reviews, there's going to be a point-of-view that the operating system is dead, which is, ah, kinda dumb. Your web browser isn't going to bootstrap that Intel CPU on its own. What might be dead is rich applications, which is a fair argument and Microsoft is failing to provide much in the way of new rich applications. In fact, we are cutting them one by one (Money, Encarta... Streets, you best watch your back). Sure, there's a transformation to online replicated services and all, but we really need to convince our consumers that there is a strong worth in having a Windows 7 on your laptop so that it's not a fancy glowy brick when the internet is down.

Kindle? Wouldn't it be sweet if we had a nice ebook reader application? We could call it... mmm, Reader?

Windows Live is supposed to help with building value via rich applications. Live has been broken out of Windows to free it from the consent decree and all ('cept for sneaking a Win7 component out early, wink-wink). Messenger, Mail, Photos, Movies, and an awkward online service. And Live Writer (though rumored a dead-man walking per comments).

It's a fair start, and if I had my druthers OneNote would move out of Office and into Windows Live to be the essential authoring companion to the Windows experience. Windows Live Essentials is a good start, but to add some joy into owning a Windows machine, what we need just as urgently is Windows Live Non-Essentials.

Joy. There's a concept just asking for a planning pillar. How strangely would your coworkers look at you during spec reviews if you asked how joyful the feature happened to be?

Windows 8: speaking of planning! The Sinofskyfication of Windows continues, along with alignment around his good lieutenants.

Office: hey, hey, hey, there's a Beta on the way. The Office train lost its conductor but it mostly seems to be still on track. Though trust me: Office wants its Steven back. Bad.

Mobile: Holy. Crap. I don't think we have any unbruised skin left on our body to take any more lumps regarding our mobile strategy. The Microsoft Mismanagement theory is in full force as we throw any willing body into the Mobile effort. Something good has to come out of those typing monkeys, rights? Windows Mobile Phone 6.5 or whatever the hell it's called didn't win any "Wows" and I discovered 1:1 the worst question to ask is, "So, can I upgrade it to Windows Phone 7?"

Look. Let's talk about device loyalty. I first started with owning PocketPCs. An HP Jornada. I loved it. When upgrade time came, HP had bought Compaq and abandoned the Jornada for the iPAQ (what, they had the iThing first?). So, unable to upgrade to the next CE, I cursed a little and bought one of those iPAQs. But HP decided not to allow it to be upgraded. So I switched to Dell to get their latest Axim PocketPC. Dell would be a safe bet, right? And Dell gave up on the line. My latest act of company loyalty: getting a powerful HTC WinMo 6 device. It was cut-off the 6.5 train, and soon, I'm going to be buying a new phone.

And I'm going to buy an iPhone.

I hate it. I hate to think that I'll be installing Apple software on one of my computers because their PC software is so inelegant and buggy (check Watson). I hate that I've been so loyal to the PocketPC platform and Windows Mobile but I've finally had my chain yanked for the last time. I'm not buying a 6.5 device only to have it abandoned when 7 comes out. Microsoft is doing nothing to convince me that it's going to get any better. We suffer through rumors that Pink is imploding and issues with Sidekick data doing disappearing acts while our CEO has conniption fits over Microsofties sporting iPhones. Dude, this is why.

In this case, Microsoft is going to have to earn me back and convince that not only do they have a better experience and better quality phone but that they also won't kick me off to the side of the road when a new release comes along, spinning a sad tale that the carriers make all the decisions.

Dev Div: If I had to sit down tomorrow and write a casual application for the PC, my mind would fork itself in about five different directions. Native with ATL? WPF? Silverlight? An HTA? And what's up with XNA? If I want to write an app for the Zune (which Zune?) what do I do? And can it run on some future mobile device? And the PC? And Xbox?

And how do I share it? How do I sell it? And, ah, crap, you mean you just released a whole new version of C# / Silverlight / XNA that I have to go and relearn? Maybe those free Starbucks coffee dispensers wasn't a good idea...

If anything, I'd probably be pretty damn tempted to invest time learning Adobe AIR. And I'm thinking that while smack dab in the middle of the Microsoft bubble. There are a lot of Partners in Dev Div, and I'm not seeing any benefit from their concentration. The Windows client should be the premiere development platform. It's not. What am I missing?

Are We There Yet? Are the layoffs over? Has Microsoft stabilized? Of course, I'd be satisfied with another 10,000 or more positions being eliminated. But I want it done in one fell swoop, like all the conventional wisdom out there dictates, so that the remaining work force can align itself and get to work and not constantly worry if their group is next. If we're going to continue this quarterly rhythm of maybe-layoffs, maybe-not then morale is going to get seriously poisoned. Let's finish this round and call it done.

Ballmer: well, Mr. Ballmer, if you ever wanted to leave on a high-note, this is it. I'm frustrated because when you hear Steve 1:1 you know that he gets it. He knows some key strategies and things that need to get done. But then Yahoo! happens. Vista happens. Over-exuberant hiring happens. Layoffs happen to shed off the over-hiring. And a flat stock price happens. So something is seriously not connecting between (a) when you hear Steve talking and (b) when he makes major decisions. Hmm. Maybe it's something about guys named Steve having localized reality distortion fields.

This week, as we celebrate Windows 7, you do see an undercurrent of knife-sharpening while examining Mr. Ballmer.

The biggest question still out there: just who would you replace Ballmer with? If a shareholder revolt was to actually happen (shyeah, right) who would be the right choice to lead Microsoft? There is no heir apparent. And no obvious motivation to find one. But wait. Maybe, just maybe... you know, we'll have to wait and see and discover if Steven Sinofsky's upcoming book One Strategy! has a chapter on 'How To Become the CEO of a 100,000 Employee Company' (hopefully followed by the chapter 'More With Less - How To Transform a 100,000 Employee Company Into a 70,000 Employee Company').

Any fireworks you're expecting this week of Windows 7 and Quarterly results?


-- Comments