Friday, June 21, 2013

x++ series: Where do call Super() ?

For everyone who has ever written a x++ code perhaps noticed to Super() method, but some times it should appear after your code and in another situation may leave it at top, before the code.

For who are new to Super() or confusing about that, let me say it means that "initialize me along with 'this' and alter the rest things". It means that everything you place before Super() will affect that initialization  and each code that placed after Super() just comes up to not alter the initialization but maybe need the objects to be ready to be used afterward or add some new functionality.

It will however more important when you are working with queries.
For example ff you are going to modify the query, by placing the code before the Super() you will make sure that query  is modified just before fetching the data;

The real world situation could be when you want to apply a filter to an existing data source on a form. In this case you have to override the executeQuery() method and place your SysQuery::findOrCreateRange(...) then put Super() at the last line (after your own code).

Thursday, June 20, 2013

x++ series: EDT (Extended Data Types)

One of important AOT objects is EDT. You have heard about Extended Data Types so far, at every job interview this is one of the questions, but no one could answer correctly nor interviewee knows the right answer and why should it is going to be asked! just MUST ask it.
Even worst, because EDT is going to be obsolete at next Microsoft Dynamics releases so developers assume they should ignore from using it.
But, actually EDT is more that these :
1) derived type.
2) Display a variable in user friendly.
3) Make it sense to relevant program's structure.
What is more?
By using EDT, you can establish a table relation which is no longer could be created from EDT node and totally moved to table node properties. It is recommended to convert all existing EDT by using EDT Relation Migration Tool in AX 2012
One of the most advantage of using EDT along with this tool is you can add a data field to a form with just a few steps with no need to define a data source relations manually then thanks to Field Groups just establish everything at once by adding this newly created field to the table's Group Field so having the relevant data in Form Design and that's it, you done!