Monday, March 11, 2013
Wednesday, August 29, 2012
Inside Microsoft Dynamics AX 2012 is available for Pre-Order
With the release of AX 2012 the market was in need of an updated book on the development aspects in X++/.NET for the purposes of extending the AX application functionality.
As some of you might know, I translated 2 of the MS Press books on AX development for the previous versions to Russian.
This time around, I was lucky enough to participate in the creation of the English version as well.
![]() |
| Inside Dynamics AX 2012 book cover |
The book is not out yet, but you can pre-order it at Amazon by using the link below
Pre-order "Inside Microsoft Dynamics AX 2012" now
Enjoy!
Posted by
Ivan Kashperuk
at
7:00 PM
5
comments
Labels: Amazon, Axapta, books, Development, Dynamics AX 2012, X++
Thursday, February 23, 2012
Tutorial: Determine if a string is a valid UtcDateTime
In my post about UtcDateTime in Dynamics AX, I recently received a question about determining if a specific string is a valid UtcDateTime in X++.I've spent some time looking into it and could not find an available method that could be used for that.
Also, it was not really clear, which format should be called valid.
Anyhow, I have so far discovered 2 ways to do it in AX: the simple way, and MY way :) They produce slightly different results however. Let me know if you find other ways.
The simple way is to use the intrinsic function str2datetime.
As you can see on MSDN, it supports a couple of input formats, and if you provide a non-date value, will just ignore it silently and return an empty value.
However, when working with DateTimeUtil methods, the expected format is yyyy-mm-ddThh:mm:ss
And, as you can see from the below test job, specifically this format is not supported by str2datetime.
So I wrote my own method based on DateTimeUtil::parse(), that returns true/false based on the string value matching the above format. This is however the only supported format for DateTimeUtil, so the other 3 examples that work with str2datetime do not work here.
Anyhow, you can download the code (I've put the method into Global) and the test job from my SkyDrive.
Test job:
1: public static void isValidUTCDateTimeTest(utcDateTime _utcDateTime)
2: {3: boolean utc1 = str2datetime("2012/02/25 23:04:59", 321) != utcDateTimeNull();
4: boolean utc2 = str2datetime("Feb-2012-25 11:04:59 pm", 231) != utcDateTimeNull();
5: boolean utc3 = str2datetime("25 02 2012 11:04:59 pm", 123) != utcDateTimeNull();
6: boolean utc4 = str2datetime("2012-02-25T23:04:59", 321) != utcDateTimeNull();
7: boolean utc5 = str2datetime("XXXX", 123) != utcDateTimeNull();
8: 9: void showResult(str format, boolean isValid)
10: {11: info(strFmt("%1 - %2", format, isValid));
12: } 13: 14: setPrefix("Date time validation");
15: setPrefix("str2datetime has multiple valid formats");
16: showResult("2012/02/25 23:04:59", utc1);
17: showResult("Feb-2012-25 11:04:59 pm", utc2);
18: showResult("25 02 2012 11:04:59 pm", utc3);
19: showResult("2012-02-25T23:04:59", utc4);
20: showResult("XXXX", utc5);
21: 22: setPrefix("Correct UtcDateTime format for DateTimeUtil: yyyy-mm-ddThh:mm:ss");
23: showResult("2012/02/25 23:04:59", isValidUTCDateTime("2012/02/25 23:04:59"));
24: showResult("Feb-2012-25 11:04:59 pm", isValidUTCDateTime("Feb-2012-25 11:04:59 pm"));
25: showResult("25 02 2012 11:04:59 pm", isValidUTCDateTime("25 02 2012 11:04:59 pm"));
26: showResult("2012-02-25T23:04:59", isValidUTCDateTime("2012-02-25T23:04:59"));
27: showResult("XXXX", isValidUTCDateTime("XXXX"));
28: }
Posted by
Ivan Kashperuk
at
4:18 PM
3
comments
Labels: DateTime, DateTimeUtil, Dynamics AX, str2datetime, utcDateTime
Tip: Illegal 'closing bracket' character when defining a macro
Just a very quick tip today, related to macros:
As you all know, there are multiple ways to define and use macros in X++.
For those that need a refresher, please look up the corresponding section on MSDN
(Direct link: http://msdn.microsoft.com/en-us/library/cc197107.aspx)
Below is a simple X++ job, that demonstrates an existing shortcoming in the #define command, and a possible workaround for this problem.
Nothing complicated, basically, just use #localmacro, if you can't compile your code.
1: static void ClosingBracketInMacroDefinition(Args _args)
2: {3: //#define.Question("Why are brackets ')' not working ?")
4: //#define.Question(@"Why are brackets ')' not working ?")
5: //#define.Question("Why are brackets '\)' not working ?")
6: #define.LegalCharacters(' !"#$%&\'(*+,-./:;<=>?@[\\]^_`{|}~\n\r\t')
7: #localmacro.Question8: "Why are brackets ')' not working ?"
9: #endmacro 10: 11: Box::info(#Question); 12: Box::info(#LegalCharacters); 13: }Thanks for finding the issue to Bogdana, one of our new developers.
Posted by
Ivan Kashperuk
at
2:34 PM
2
comments
Labels: Bug, Dynamics AX, illegal character, job, Macro, workaround, X++
Friday, January 20, 2012
Microsoft Dynamics Salary Survey 2012 - Please participate
I don't usually make posts like this, but this is one of those things I always look forward to reading when it comes out, so I decided helping the guys out won't hurt :)
What I am asking from you guys is some time (2 minutes or so) to fill out the survey below about how much you make, what kind of benefits you get, where you work, and so forth. It's anonymous, obviously, and every participant will get a copy of the report afterwards. And this time around, you can even win something for participating! So please do.
![]() |
| Participate in the survey about Dynamics |
1st Prize = Apple iPad2 16gb with Wi-Fi + 3G
2nd Prize = Microsoft Xbox 360 250gb + Kinect
3rd Prize = Kindle Keyboard with Free 3G + Wi-Fi
4th Prize = Microsoft LifeCam Studio Webcam
5th Prize = Microsoft Arc Touch Mouse
Posted by
Ivan Kashperuk
at
11:23 PM
2
comments
Labels: Free, iPad 2, Kindle, Microsoft, Microsoft Dynamics, Nigel Frank, Salary, Survey, XBox
Wednesday, November 09, 2011
Tutorial: Debugging AX while still using restricted roles (non-admin)
Saw this on our internal forum today, and thought it's a nice thing to share with all of you.
SecurityUtil::sysAdminMode(false);
Note: This will not work for EP, Services, direct BC.NET and cases using runas(), as the SecurityUtil::sysAdminMode is limited to the current session.
Ed Budrys from our Security team deserves the credit for the above.
Let me know if you found this to be useful.
Thanks
Posted by
Ivan Kashperuk
at
9:12 PM
3
comments
Labels: Admin, Debugging, Development, Dynamics AX 2012, Environment, Role based security, Security
Friday, October 28, 2011
Tutorial: AX 2012 - Invalid field access or Accessing unretrieved fields
Read the post all the way until the end - there's an ask for you guys there!
As many of you have already seen in the new AX 2012 release, there are a lot more tables present in the application, because we went through an exercise of normalizing the data model.
Another feature that was added at the same time was the Table Inheritance, allowing to sub-class tables and add additional fields reusing some of the behaviors of the base table.
All of it is great! The only problem with it is that it comes at a price - we now need to retrieve a lot more data and do a lot more joins between tables. So we tried to mitigate that by using field lists where possible and adding AdHoc query support, which basically eliminates unneccessary joins between tables from the hierarchy, if fields from these tables are not selected.
We have also implemented a number of things that allow us to clearly see if the field was selected in the user interface, the APIs needed for doing the same, as well as special handling for invalid field access.
This tutorial contains a form, which showcases the different aspects of data access in cases described above.
You can download the project with the tutorial from my SkyDrive.
On the first tab, we have the standard "On hand" view, which in the data model is a join between InventSum and InventDim, with group by clauses on selected fields, in this case, ItemId from InventSum and InventLocationId from InventDim, and aggregation on the AvailPhysical column.
As you can see from the screenshot below, the rest of the InventDim fields are shown as Unretrieved. So, naturally, accessing one of them from code, for example, should not be a legal operation.
To verify that statement, there are 2 buttons on the form, the Incorrect and the Correct was of accessing the field. Clicking on the first one simply tries to read the value out of the InventSiteId field, while the second one uses the API method TableBuffer.isFieldDataRetrieved() to first verify if the field can actually be accessed.
Note, that in the below example, both buttons will work, as in, there won't be any errors shown to the user. When accessing the field, even though it is not retrieved to the client, the value will be treated as the default value for that type, that is, an empty string.
In order to verify that we do not access fields in an invalid way like above, we have introduced a parameter, that will throw an exception if a field that was not retrieved is being accessed.
In order to enable this validation, you need to update the below shown parameter in the Server configuration form (Located under System administration \ Setup \ System). After changing the value (note, that it is per AOS) you need to restart the AOS for the changes to take effect.
Now, if you try to use the first button (under Incorrect) from above, you will get a stack trace, notifying you that the specified field was not retrieved.
We suggest that when testing your modifications in the application, you always have that flag enabled, so as to avoid unpleasant and hard-to-find bugs later on in the production environment.
On the second tab of the Tutorial form, the same type of information is presented, only this time the output is actually based on a new table inheritance structure I created.
The base table, GenericBall, contains 2 characteristics of any ball. SoccerBall is extending it and adding an additional characteristic (for the sake of the example, let's assume Brand is only relevant to soccer balls). This is basically a very simple table inheritance structure.
In the form, however, I am only selecting to view the Brand field from SoccerBall, not selecting the other 2 fields from the base table. As expected, they show up as Unretrieved in the user interface.
However, there is one difference in how Scsc tables are handled - and that is, they will always throw an exception when you try to access one of the unretrieved fields.
The two buttons above the grid demonstrate that. Try it out, enabling/disabling the server configuration parameter shown above.
That's pretty much all there's to it. Let me know if you have any questions.
Now, I have one thing to ask you all too.
We in the AX Test team have done our best to find invalid field access problems before the release, but if you find one using the approach above, please log it either through the standard Microsoft channels (partner/ MsConnect/ etc.), or as a comment directly under this blog post.
Thank you!
Posted by
Ivan Kashperuk
at
11:54 PM
11
comments
Labels: data model, Dynamics AX 2012, field access, Form Development, Microsoft Dynamics AX, Performance, retrieving data, server configuration, Table, table hierarchy, table inheritance, tutorial
Monday, October 24, 2011
Tutorial: AX2012 - A new way of accessing the QueryBuildDataSource for a particular FormDataSource
When playing with some X++ code, I found an interesting addition that happened in AX 2012 related to form development.
There are 2 new methods that were added to the FormDataSource class, which allow you to very easily and error-free access the underlying QueryBuildDataSource, whether that is for the initial form query or for the queryRun that also contains user filters and sorting.
So, for example, instead of writing:
this.query().dataSourceTable(tableNum(InventTableModule), 2);
this.queryRun().query().dataSourceName(identifierStr(Purch));
....
you can use the 2 new methods:
this.queryBuildDataSource();
this.queryRunQueryBuildDataSource();
It might seem as a very minor improvement, but in reality it greatly simplifies maintenance of code on forms, when new datasources are added or existing ones removed/renamed.
That's all for today.
Posted by
Ivan Kashperuk
at
3:09 PM
0
comments
Labels: Dynamics AX 2012, Form Development, FormDataSource, Query, QueryBuild, QueryBuildDataSource, QueryRun, tutorial








