Thursday, February 16, 2017

AXBUILD fails with a "System.IO.IOException: The file exists" error

Here is a problem with AXBUILD that today added more grayness to my limited amount of hair:

The reason: When AXBUILD kicks off the compilation-threads it needs some temporary files and it uses a .NET function to get the names. It turns out that if the user this runs as, has more that 65535 files named as tmpXXXX.tmp in the Temp folder, the function can simply fail. The naming apparently runs from tmp0000.tmp to tmpFFFF.tmp. 

So the solution was to clean up this folder for our build user, and now all our builds are running again.

Friday, January 6, 2017

Authoring Best Practice checks that use XML based input

In AX7 you can pretty easily write and deploy your own Best Practice checks. The process of doing so is described in this article on the wiki.

Some of the standard Best Practice checks use XML files as input. These XML files are found under your local packages folder, in ..\PackagesLocalDirectory\Bin\BPExtensions\RuleXml

The following is an example of how you can write your own Best Practice check that uses an XML file as input. The check itself is used to check the naming of table extensions. We want to check that a certain prefix is part of the name, and that it is put in the correct place in the overall name. The prefix to look for is specified in the XML file.

The XML file looks like this:
The file is stored in ..\PackagesLocalDirectory\Bin\BPExtensions\RuleXml and the name is MVPProductPrefix.xml. The name is important, as a reference is made to it from the code.

Your Best Practice class needs to extend either DetectorWithXMLDataFile or MetadataDetectorWithXMLDataFile depending on the type of your check. In this case we extend MetadataDetectorWithXMLDataFile since we will be looking at table extension names.

Included in your solution you need to add a data contract class for the XML file. This class must extend from RulePatternsBase.
The framework and the base classes will then do the rest of the work with loading the XML file, de-serialize it and caching it.

Here is the code:

And here is the code for the diagnostic item:

I'd like to thank Joris de Gruyter for helpful hints on how to solve this. And .NET Reflector has been a great tool to look into the standard Best Practice dll's to figure out how they work (Microsoft MVPs get a free license for .NET Reflector from Redgate).

Wednesday, December 7, 2016

A dynamic query range for month to date (SysQueryRangeUtil)

Here is the code for creating a month-to-date filter:

public static str monthToDateRange(int relativeDays = 0)
    utcdatetime currentDateTime;

    currentDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), 

        DateTimeUtil::date(DateTimeUtil::addDays(currentDateTime, relativeDays)));

The code must be added to the SysQueryRangeUtil class.

Use it like (monthToDate(n)) where n is the number of days from today. So month-to-date-yesterday would for example be (monthToDate(-1)).

Thursday, December 1, 2016

First place to look when batch seems not be working i AX7

When you can see that the batch service is not really picking up any jobs, the first place to look is normally in the batch group setup. Here you'll validate that the different batch groups are connected to a batch server.

And here comes the fun part where AX7 might trick you, if you not on your toes. The selection panels for Selected and Remaining servers have switched places since AX 2012...

Here is the dialog in AX 2012:

And here it is in AX7:

A thank you goes out to Lau Larsen for pointing this out.

Thursday, November 24, 2016

Difference between "Local" and "Remote" settings in the "Run mode" property of a form part

Recently I was wondering what the difference between the "Local" and "Remote" settings in the "Run mode" property of a form part actually meant. I couldn't find any documentation on the wiki.

In a Microsoft Yammer community Harold Albrich of terna GmbH pointed me to an earlier answer in the same forum. Since this blog also serves as my own notebook, I'll share my version of the answer here:

When the form part is called as Remote, there is no coupling between the form part and the caller form. So no linking of data sources and also no element.caller() object. And as Remote the form part is executed in a separate session.

With Local it is the other way around. You can link data sources and you can work with element.caller().

Tuesday, October 25, 2016

SQL Server trial license expired on your cloud boxes for AX7?

If you have made deployments before summer, you might have deployments where the SQL Server is installed with a trial license and it is set to expire november 1st. When it expires you are not able to start the SQL Server service anymore.

Here are the necessary steps to update SQL Server:

  • Obtain a valid installation media and license. 
  • Stop the "Hyper-V Time Synchronization Service" service.
  • Change the system date on the server, to a date before the trial expiry date.
  • Run SQL Server installation and choose "Upgrade from preview version"
  • Start the "Hyper-V Time Synchronization Service" service again.

The reason for changing the system date is that the upgrade won't run if it can't start the existing SQL Server service.