Category Archives: Development

Posts about development in Dynamics AX 4.0 or Axapta 3.0

Sorting containers with multiple levels

I encountered a scenario where I wanted to find a record of a certain type somewhere in a big container. This got med thinking, and the result is the code below. I wanted to be able to loop through a container no matter how big it was or how many levels of new containers it contained.

This job searches through the container con1 and sorts the types Integer, Real and String into separate containers. In itself this job might not be very useful, but my goal was to build something that could easily be modified to work in many different cases when looking for different values in containers.

It also finds the specific records of VendTable, CustTable and SalesTable that I hid inside the container structure.
Continue reading Sorting containers with multiple levels

A quick look at lists and a bit of XML

This is just a quick look at the List object in Dynamics AX. Just played around with it to see what functionality was there and what wasn’t. As you can see I just created a simple list of integers and also one with records from InventTable, if you wan’t to know what types can be placed in the list, check out the baseEnum “Types” in the AOT.

As a bonus I also created a xml file of the list of integers.

Continue reading A quick look at lists and a bit of XML

AIF – Wrong field ID in the key data container in entity key

@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!

How to colour code different companies inside axapta

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

How to catch special keystrokes and use them as shortcuts

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

How to clock routines which (should) go faster than 1 sec

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

Open filtered forms with X++

When using forms in Dynamics AX we usually get access to them by clicking a button that uses a menu item, this along with the args that is sent we get a form that displays the requested information. But if you want to do this using code, how is this done?

You usually see this used in classes such as SalesFormLetter or PurchFormLetter that uses an existing form instead of a creating a temporary one. The user enters the information and the class uses the new information to perform the tasks at hand.
Continue reading Open filtered forms with X++