Just found a strange behaviour in using the standard str2enum function. Consider the following code ;
static void TestOfEnumsWithFirstValueBlank(Args _args)
selectedType = ProjCategoryType::None;
s = enum2str(selectedType); // get enum string
print s; // shows nothing, since None has no label.
selectedType = str2enum(selectedType,s); // convert back
if(selectedType == ProjCategoryType::None)
print "'None' selected";
print "undefined..."; // sadly this is printed..
This example code prints undefined, NOT ‘None’ selected. This because str2enum does not handle an empty string in a correct way, even if one of the values in the choosen enum has the emptry string as it’s label. This means values to str2enum must always be validated first before each call..
Have you searched the net for how to store documents in an AX table? I did, a lot.. When I couldn’t find it, I had to do it myself 😉 Here is a short description on how to store, download and edit documents from AX in Office (or any..) program.
Continue reading How to store and retrieve an Office document from/to an AX table.
If you ever encounter this error message in Ax4sp2 and you are one hundred procent certain that there is nothing wrong with your file, check the MessageId tag. This sequence can not just be increased by one all the time, sometimes you come to a combination which simply does not compute..
Continue reading AIF – Invalid Message Schema … ??
When you work with the AIF and xml files, you often need to handle so called “white-space”. The normal AX functions strltrim() and strrtrim() only handles normal space (ascii 32), these are two examples which handle all kinds of spaces in files. Small and simple, but very handy. 🙂
Continue reading AIF – How to get rid of white-space in AX?
@SYS92355 = “Wrong field ID in the key data container in entity key”
This error message from the AIF in AX4sp2 did give me some headache today..
Finally I solved it. I was about to export a SalesOrder with both header and lines, but I did put my sendElectronically method in the SalesLine table, *not* in SalesTable table.. So when executed I never got the correct keys. The query I used for the axd wizard was based on SalesTable first, and THEN SalesLine..
Might help someone else with the same or similar problem!
If you use a descriptive text on your profiles you use to startup axapta with, you have here another way of a very clear presentation of which installation, db, etc settings you are running under.
Continue reading How to add current profile name to the window title
During development and test we often switch between different companies in our installation. To not mistaken us, so we always make changes in the correct one, we made this small change in the code. With different background-colours for each company, you never delete something importent by mistake. This example shows how it could be done.
Continue reading How to colour code different companies inside axapta
Rightclick on a form and go down tracking a specific field or other data, is a tedious work if you do it dozens of times per day.
We wanted to catch the key combination ctrl+Z (since it is rarelly used when running axapta), so we could use it to display common data about a form, field or other info. This is a code example we nowdays always install in all new test and development environments (not production, since it would give normal users unwanted access).
Continue reading How to catch special keystrokes and use them as shortcuts
From the basic routines in Axapta we only have the TimeNow() function which returns number of seconds since midnight. To measure something more exact than that, we either need to do an API call to getTickCount or to use the setTimeOut() function. This is a small demo on how to implement both such timers.
Continue reading How to clock routines which (should) go faster than 1 sec
I was building an extended search form for one of our customers. When called from one form everything worked fine, but when called from a second form my grid only contained one record… Exact same parameters, same menu item etc. When looking around I found that when the error occured, I was calling from a form which had same table (InventTable) as one of it’s main Data Sources. This is one of the non-documented features in AX, if same table exists in the Data Sources in both forms, AX tryes to link them together. To break this connection I had to call ClearDynaLinks() on the second form. Like below, in my search form’s init method.