Extensible X++: Chain of Command

As you can see on the Dynamics Roadmap a new capability is being introduced in X++; it enables strongly typed extension capabilities of public and protected methods; including access to public and protected members. Oh; I almost forgot: This is my new favorite X++ feature. See this video to learn more. THIS POST IS PROVIDED…

42

X++, the catch

“When building a cannon, make sure the cannon ball comes out in the right direction.” This is a piece of advice I heard many years ago. I think, we in generally have been following the advice in the Dynamics AX platform group. The APIs and designs have been easy to understand, and without side-effects. This…

23

C# 7.0 – an X++ developer’s dream coming true?

  Today I attended an excellent TechTalk on C# 7.0 by Mads Torgersen at a full house in Microsoft Development Center Copenhagen.   As the talk unfolded I was struck by Déjà vu– this is not the first time I’ve heard Mads present a new feature in C#, that I’ve been using for a long…

8

X++ in AX7: Attributes without specifying ”Attribute”

The naming convention in X++ (and C# by the way) is to postfix attribute classes’ name with “Attribute”. When using the attribute to decorate a class, it is a bit verbose to type in “Attribute” as it is apparent from the context, so now in X++ – just like in C# – you can skip…

0

X++ in AX7: String truncation

Consider this X++ code:  CustGroupId id = “012345678901234567890123456789”; //30 chars long;   CustGroup custgroup;   custGroup.id = id;  custGroup.insert;    select custGroup     where custGroup.id == id;   The CustGroupID EDT is defined with a length of 20 characters. In AX 2012 the assignment in the very first line would truncate the string from 30 to 20 characters. The record would be inserted and selected again. In AX7 the CustGroupID EDT is being compiled as…

2

X++ in AX7: Garbage Collection

In AX 2012 the runtime can either be the .NET CLR executing IL code, or the AX interpreter executing pcode. From a Garbage Collection point of view these two behaves extremely different. The difference is like night and day.   In AX7 only the .NET CLR Garbage Collector is in play.        …

0

X++ in AX7: Method signatures

This post is about one of the more subtle changes in AX7. AX7 uses the .NET runtime, aka CLR. This has some implications for method signatures. In the CLR a method’s signature includes casing, parameters and return type. In AX2012 a method’s signature was simply the method’s name – case insensitive. Why is this important?…

2

X++ in AX7: Inline variable declarations

What would you pay to be able to do this in X++? for (int i = 1; i <= n; i++)   {}     Or this: if (i > 0)    {    int positiveInt = i;  }   Or this: if (applyInterestRate){    real rate = this.getInterestRate();      result = result * rate;  }  if (applyExchangeRate) {      ExchangeRate rate = this.getExchangeRate();      result = result * rate.ExchangeRate;  }   Finally, we can: Declare variables close(r) to where they are used, Variables are scoped by the block in which they are declared, and Variable names can be reused in another scope. The price: Join…

0

X++ in AX7: Const keyword

In AX7 X++ now supports the const keyword. Semantically it is identical to const in C#. In short; it allows you to define members on a class and variables in a method that can only be initialized during the declaration. The compiler will replace references to these constants with the literal value. In other words,…

5

X++ in AX7: Extension methods

Have you ever experienced a Microsoft provided class or table missing that vital method that would just make your life easier? If so, you might have been tempted to add it yourself using overlayering. And you surely have paid the upgrade price! You are about to be pleased. In AX7 X++ supports extension methods, similarly to…

15

X++ in AX7: Readonly keyword

In AX7 X++ now supports the readonly keyword. Semantically it is identical to readonly in C#. In short; it allows you to define members on a class that can only be initialized in the declaration and in the constructor. class MyClass {      readonly str identifier = “XYZ”;      readonly str identifier2;       public void new(str _identifier)     {          identifier2 = _identifier;      }       public void foo()     {         // The field ‘identifier2’ is read only. A value cannot be assigned to it.         //identifier2 = “ABC”;       }  }   The big question is “when to use it?” In my opinion the…

0

X++ in AX7: Reals are decimals

In AX2012 reals are compiled as System.Decimal when compiling IL code. In AX7 that is the only option. The main difference between the two is the maximum value supported: AX 2012:AX 7: ~ 9E127~ 8E28 Both numbers should be large enough for most ERP scenarios – but you could get burned when doing arithmetic. For…

0

X++ in AX7: Internal keyword

internal is a new keyword in X++. It has the same semantics as in C#. When you mark a class or method as internal, then it can only be accessed from within the model where it is defined. internal class MyInternalClass {      internal void myInternalMethod()     {      }  } Notice, you can define internal methods on public classes too.   THIS POST…

6

X++ in AX7: Static classes

You can now mark a class as static. static class MyClass{}    It will not be possible to create instances of this class. This is useful for classes providing static methods only – like the Global class.   THIS POST APPLIES TO MICROSOFT DYNAMICS AX7 TECHINCAL PREVIEW; IS PROVIDED AS-IS AND CONFERS NO RIGHTS.

3

X++ in AX7: Static event subscription

In AX2012 we introduced events. Unfortunately, we got the subscription part of static events upside down. In the meta model you were forced to change the publisher when adding a subscriber. This resulted in an intrusive customization. And thus defeats most of the purpose. In AX7 this has been corrected. You can now subscribe to events using the…

6

X++ in AX7: Client/Server keywords

In AX7 all X++ code is running on the server tier. No exceptions. The compiler is ignoring client and server keywords.   When you come across any of these just delete them without a second thought: Client and Server keywords //AOSRunMode::xxx xGlobal::ClientKind() Dangling semicolons (but that is another story)   Similarly, if you stumble into…

1

X++ in AX7: Static members

You can now declare class member variables as static. The semantics are the same as in C#; namely that all instances of the class will share the member, e.g. if one class sets the value, another class can get it. In AX7 static members are scoped by the session, i.e. two sessions will not share the…

10

X++ in AX7: Private and public members

Since the first version of Axapta, member variables in classes have been protected. In AX7 the default remains protected, however, you can now mark them as public or private.  Here is an example:  class MyClass{          public int PublicMember;          private int privateMember;          int protectedMember; //Defaults to protected      protected int explicitlyProtectedMember;  }     You can access the public member using the same syntax as when accessing fields on Tables (or properties in C#). Notice…

2

X++ in AX7: Type declarations can be 80 characters

Since the first version of Axapta developers have suffered a limitation of 40 characters when defining types, like classes, tables, extended data types, and even when defining methods and fields.     This limit was at first completely removed, to the joy of us developers who could now come up with some really crazy method…

1

X++ in AX7: Finally and using

Finally, X++ got support for the finally statement. It has exactly the same semantics as in C#. This means that you can now write:  try {}     catch {}      finally {}        The contents of the finally block is guaranteed to be executed – regardless of exceptions or transactions. It is typically used to clean up any usage of none-managed resources. And…

5

X++ in AX7: The var keyword

This is the new language feature that is generating most discussions. Just like C# you can now use the var keyword when declaring variables. It has the exact same semantics, and any guideline you will find on how to use it in C# will also apply in X++.     In C# the var keyword…

9

Garbage Collection and RPC calls in X++

Dynamics AX is a 3-tier application that evolved from a 2-tier application.  Yes, this is right, the first versions of Axapta was solely a client side application communicating with the database. In version 2.0 the middle tier was introduced. The X++ language got a few new keywords, client and server, and the AX run-time provided…

6

X++ Debugging Tips and Tricks #4 – Reading uncommitted data

  This next trick in the X++ Debugging Tip and Tricks series is invaluable when stuck deep in a debugging session, and want to verify that the SQL statements being executed has the intended behavior. For illustrative purposes, I’ve created a small job. It updates the customer group to “40” for the customer with account number…

2

X++ Pedal To The Metal

This is a post I’ve been waiting to write for quite a while – but it had to wait until R3 became available. The SysExtension framework offers some great capabilities, but unfortunately it also comes with a performance penalty (in R2). A while ago I set out to understand where the time was spent, and…

8

X++ Debugging Tips and Tricks #2 – xSession::xppCallStack()

In the first trick we saw how to set a breakpoint in the add method on the info class. This enables us to get the context of a single error.   But sometimes error messages come in hoards and stepping through each of them is not practical. Suppose you have hundreds or even thousands of errors…

3

X++ Debugging Tips and Tricks

I hate debugging – I would much rather write code or watch tests execute! Debugging is a waste of time, and often follows an unpredictable path. Any developer knows the situation: A bug is discovered, and the cause must be found. Most developers have these war stories on how they fought with a bug. The…

3

Debug::Assert in X++

Update 4th of August 2014: Clarification of the AX runtime behavior when non-developers hit an assert statement.   “In computer programming, an assertion is a predicate (a true–false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place.”     http://en.wikipedia.org/wiki/Assertion_(computing) What would you rather have: A piece of…

3

TypeScript TechTalk at MDCC

Recently Technical Fellow Anders Hejlsberg visited MDCC. He presented the latest landmark he has been working on: TypeScript. TypeScript enables compile time checking of JavaScript code – namespaces, OO classes etc. Further it gives you great tooling – such as auto-complete and refactoring. TypeScript is implemented in JavaScript and can be used in any existing…

0

"Internal error 25" causes and solutions

This article applies to Microsoft Dynamics AX 2012. The error message ”Internal error 25” is a generic error message that occurs when one type is trying to be converted into another incompatible type at runtime. This error can be triggered in a myriad of different situations. However; there are three likely root causes to this….

0

Dynamic objects in C# 4.0 …and X++

C# 4.0 which recently has been released introduces a new static type with the name dynamic. The semantic of declaring a variable as dynamic is to defer all type checking from compile-time to run-time.  This feature doesn’t enable new run-time capabilities, but it certainly makes your code more readable – especially when you interacting with…

0

Optional parameters in C# and X++

In the upcoming 4.0 version of C# the language now supports optional parameters – just like X++. The following is a valid method declaration in both languages: public void foo(int parameter1, int parameter2 = 0, int parameter3 = 100){} There are a few differences between the languages with regards to optional parameters: Named parameters In…

3

New X++ Editor

Vincent Nicola from our VS Tools team has posted a blog on the new X++ editor coming in AX6. This certainly is an interesting time to be an AX developer. http://blogs.msdn.com/vnicolas/archive/2009/10/11/dynamics-ax6-the-new-x-editor.aspx

1

AX models – Part 4 – Working with models inside MorphX

This is my final post on models in AX for Milestone 2 (M2). Since my last post (link) the Dynamics AX organization has exited M2 – this means that all planed M2 features are implemented, tested, and all exit criteria passed. The exit criteria ensure quality by enforcing a required bar for a number of metrices across all teams, such…

1

Channel 9 Screencast: 10 MorphX tricks in 10 minutes

A new AX screencasts is now available on Channel9. It shows 10 small demos that will make you more effecient as an MorphX / X++ developer. Here is the link: https://channel9.msdn.com/posts/mfp/10-MorphX-tricks-in-10-minutes/ [Update: Media issue has been resolved.]

1

AX6 sneak preview – elements with 32 bit IDs

In AX4 we added Unicode support. On one hand it seems like a minor thing, it is just the storage format of strings – on the other hand it literally opens up a new world of opportunities. From a technical perspective it was a major surgical challenge; not many system files remained untouched in the process….

4

AX6 sneak preview – SQL AOD

Today we built the first official build of Dynamics AX ever that does not run on AOD files. Starting today Dynamics AX’s model database is stored in a Microsoft SQL Server database. Seen from within MorphX you hardly notice the difference. Everything works as it used to; there are no new feautures; but yet it feels…

14

AX6 sneak preview – X++ Unit test improvements

These days the first milestone of AX6 is being completed. It means the first wave of new functionality has been implemented, tested and documented. As always; it is an exciting time to be working on AX… One of the features coming in MorphX in AX6 is set of improvements in the X++ Unit Test framework….

5

Dynamics AX 2009 Version Control Interview

At Convergence in Copenhagen 2008 Morten Jensen (PM in the MorphX Team) and I were interviewed by Ben Riga on the version control integration in Dynamics AX 2009. In AX 4 we first introduced version control with integration to SourceSafe.  In AX 2009, we introduced Team Foundation Server (TFS) support as well as a MorphX…

1

What’s up with this semicolon?

The most visual idiosyncrasy in X++ is the dangling semicolon separating the variable declarations from the actual code. But why is it there and why is it needed? Best practices in X++ (as in most other modern languages) suggest using TitleCase when declaring (and referring to) types, and using camelCase when declaring variable types. Here…

11

We did it (again)!

On behalf of the Dynamics AX 2009 development team I’m proud to announce that as of build 5.0.529.0 we have reached zero X++ best practice errors in the SYS layer. Version 4.0 was the first release of Dynamics AX without any best practice errors. Reaching this level of code quality was a mammoth effort; due to the…

5

Writing less code: The "else" statement

Source code is written once; and read over and over again. So make sure it is easy to read and understand. I keep seeing a poor coding practice. I see it in production code, in test code, in X++ code, in C# code, in C++ code, in examples on the web, when interviewing candidates. I…

17

Anyone interested in developer documentation of X++ code?

A new feature in Dynamics AX 2009 enables developers to write developer documentation directly in the X++ Editor while writing the production code. The feature is very similar to the XML documentation feature in C#. Basically any method can contain /// (triple-slash) comments followed by structured documentation in XML format. Here is an example: The developer…

8

Version control for everyone

With Dynamics AX 5.0 there is no longer an excuse for not using a source control system when developing in MorphX. The version control integration options in Dynamics AX 5.0 both cater to larger development organizations by seamlessly integrating with Visual Source Safe and Team Foundation Server, and to smaller development teams who cannot afford…

3

Dynamics AX 4.0 Meta Model

If you are a new developer and is trying to ramp up on AX, this might be a post for you. In MorphX (the IDE for AX) you do model-driven development. This basically means you create new elements of certain concepts, decorate them with properties, and wire them all together. Naturally there will be requirements…

0

Compiler warnings – and so what?

Every so often I find myself in a heated debate on what the quality bar should be for the code in the solution we are working on. This is an important debate, and for the project’s success it should not be down prioritized. The quality bar may vary from project to project: If you are…

4

Articles on X++ development

While digging in my archives to service a request from a co-worker I stumbled across a few articles I wrote for Damgaard Technet. Those that are still valid, I’ve polished a bit and made available here. Behavioral information messages How to use a form tree control Delaying method calls The user friendly Infolog Showing operation…

0

Behavioral information messages

A concept for displaying behavioral information messages exists in Dynamics AX. A behavioral information messages is a context sensitive message informing the user about a better way of performing an action or about how to perform a not obvious but often used task. Introduction Situations may occur where the user is performing a perfectly legal…

0

New blog from the X++ compiler team

Make sure to check it out: http://blogs.msdn.com/x/ They already got a cool post on how to implement the observer pattern in X++.

0

Microsoft Dynamics AX Developer Center: Your one-stop resource center for AX Development

This is the lastest of great AX resources becoming available. This site is an umbrella site for existing information. It ties together news groups, blogs, training materials, downloads, online documentation, and much more.http://msdn2.microsoft.com/en-us/dynamics/ax/default.aspx It didn’t take me long to realize this should be my default home page for my iexplorer – this is a site I’ll be…

1

Channel 9 Screencast – MorphX Best Practices

The new installment of AX screencasts is now available on Channel9. It is a 20 minute video on MorphX Best Practices in Dynamics AX 4.0 – one of my favorite topics! Here is the link: https://channel9.msdn.com/ShowPost.aspx?PostID=292988 I’ve attached the PowerPoint slide deck to this post. The deck contains a transcript of the talk in the slide notes. MorphX Best Practices.ppt

3

Channel 9 screencast – Application Fundamentals

The next installment of AX screencasts is now available on Channel9. It is a 38 minute video on Application Fundamentals in Dynamics AX 4.0. Here is the link: https://channel9.msdn.com/ShowPost.aspx?PostID=284365 I’ve attached the PowerPoint slide deck to this post. The deck contains a transcript of the talk in the slide notes. If you prefer reading to my voice, I won’t…

0

Channel9 – AX screencast on Exception Handling in X++

A brand new AX screencasts is now available on Channel9. It explains how exception handling in X++ and how exceptions are integrated with the Infolog in Dynamics AX 4.0. Here is the link: https://channel9.msdn.com/Showpost.aspx?postid=273765  

0

Holiday season crossword – final day!

If you still haven’t participated in the crossword challenge you can still make it. Today is the final day of entry – tomorrow I’ll be drawing the winner. I will of course use X++ to help me find the winner. I will generate a random number (n), and winner will be n’th reply in my Outlook mail…

0

Channel9 – AX screencast on Smart customizations

The next installment of AX screencasts is now available on Channel9. It is a 30 minute video on Smart customizations in Dynamics AX 4.0. Here is the link: https://channel9.msdn.com/ShowPost.aspx?PostID=267428 Over the coming months I plan to create more screencasts on general development topics in Dynamics AX. If there are any specific topics you would like a screencast to cover,…

1

Holiday season X++ Crossword

As the holiday season draws nearer, what is more appropriete than giving away a nice prize. To challenge you a bit I’ve greated a small crossword. In the spirit of AX the crossword is only using X++ system functions – so if you are stuck, you can start up your favorite AX client to get some hints. The prize is:…

1

Channel9 – AX screencast on 3-tier development

The second installment of AX screencasts is now available on Channel9. It is a 34 minute video on 3-tier development in Dynamics AX 4.0. Here is the link: https://channel9.msdn.com/ShowPost.aspx?PostID=259048 Over the coming months I plan to create more screencasts on general development topics in Dynamics AX. If there are any specific topics you would like a screencast to cover,…

0

Building a layer file from XPO files

Updated 30-06-2012 official beta version available here: http://informationsource.dynamics.com/RFPServicesOnline/Rfpservicesonline.aspx?ToolName=Microsoft+Dynamics+AX+2012+Combine+XPO+Tool+Beta+1.0 Updated 14-01-2011 to support UniCode XPO files. Notice the change in parameters. So now you are using version control – and you just realized the master is no longer the AOD layer file, but instead a zillion of XPO files. Still you want to provide an AOD…

20

TechEd 2006 count down

I can’t believe it – Tech-Ed 2006 is next week!   Browsing through the session catalog brings back the excitement from previous years. And this year the contents are even more exciting with all the product launches happening: IE7, Vista, Office 2007 – just to mention a few. You may also have noticed that the number…

0

Channel9 – AX screencast on Unit Testing

I’ve just uploaded my first AX screencast to Channel9. It is a 20 minute video with a demo of the Unit Test Framework in Dynamics AX. Here is the link: https://channel9.msdn.com/ShowPost.aspx?PostID=247301#247301 Over the coming months I plan to create more screencasts on general development topics in Dynamics AX. If there are any specific topics you would like…

1

MorphX Metrics

Do you have the overview of the number of compile errors/warnings/to-dos and best practice errors in your customizations? Do you have the information broken down per team or even by module? Do you have an overview of the size of your customizations? If you answered Yes to all the questions above read no further! The heart beat…

1

Channel 9 on Model Driven Development

In this ½ hour video Arthur Greef interviews me on the model driven development architecture of Dynamics AX. Small demos are shown during the interview including the powers of IntelliMorph and the layer technology. https://channel9.msdn.com/ShowPost.aspx?PostID=235384

0

Writing Secure X++ Code

Last week a document on security considerations for Dynamics AX development was published.This 40 page document is a must-read for every X++ developer. Topics covered: How to use dangerous APIs in a safe manner Code Access Security in X++ Data Authorization Credentials and Cryptography Server-side batch processing New best practice rules (Those prefixed with “TwC”…

0

I want developer documentation!

The solution is here! The developer documentation for Dynamics AX has moved to a continuing publishing model. This means more and more documentation topics will be available as they are written, and not as previously only when a new version is released. However, despite good intentions, the developer documentation released with Dynamics AX currently primarily contains the…

0

Cryptography API in X++

In version 3.0 the class TextBuffer had two methods: Encrypt and Decrypt. For version 4.0 the Encrypt method has been removed, and the Decrypt method renamed to DecryptOld. The change happened for security reasons. If you require to encrypt and decrypt strings in Dynamics AX 4.0, you can use the functionality provided in the .Net…

4

Showing Operation Progress

The operation progress form The form showing the progress has five important parts:1. Caption2. Animation3. Operation description4. Progress indicator5. Time remaining calculation Initialization Before you can begin, you must initialize the class SysOperationProgress: SysOperationProgress progess = new SysOperationProgress(); Alternatievly you can use on of the static new methods on the SysOperationProgress Class. Setting the caption…

2

Global variables

The need for global variables often arises because of flawed implementation design. However, when used for caching purposes global variables can provide performance boosts. This article describes how you can implement a global variable with zero maintenance during upgrade. Why use this approach? Using the approach described below, no standard application classes are modified and…

1

The user friendly Infolog

When the user receives a message in the infolog, he is interrupted in his work. It is crucial for the user to be guided in the best possible manner, so he can continue his work. Use short informative messages Give the user a message he can use. Do not use error codes or similar and do…

3