Pages

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).

Friday, December 30, 2016

Monthly curated list of AX development news from the community - 2016 12

Here is the shortlist of what I think is the most important developer community news from this month.

X++, the catch
Create a new language in Microsoft Dynamics 365 for Operations
How to solve AX Data Refresh with Powershell?
Find assembly for a given type – in AX 7
Testing AX7 OData services with Fiddler
ssms-visualstudio-addin
Extensible control – HTML/JavaScript
Extensible control – X++ classes
How To: Extending report menu items

This is a list I try to keep as short as possible, making it manageable for most people to look through the articles on the list. If your article is not on the list, I may have overlooked it (hope not) or it fell for the prioritization of making this list short. I have a lot more ongoing links on my Twitter profile and my Flipboard magazine.

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::getUserPreferredTimeZone());

    SysQueryRangeUtil::dateRange(
        dateStartMth(DateTimeUtil::date(currentDateTime)),
        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.

Friday, November 25, 2016

Monthly curated list of AX development news from the community - 2016 11

Here is the shortlist of what I think is the most important developer community news from this month. And yeah, the month isn't over, but it's a Friday thing for me.

This is a list I try to keep as short as possible, making it manageable for most people to look through the articles on the list. If your article is not on the list, I may have overlooked it (hope not) or it fell for the prioritization of making this list short. I have a lot more ongoing links on my Twitter profile and my Flipboard magazine.

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().