Friday, 18 March 2016

Dynamics AX 7 - Searching using BaseX

In a previous post I wrote about the benefit of being file based model store. It allows for quick searching. On top of this the files being xml it allows for using complex searching using XPath and XQuery to find properties. There is a tool out there called basex which is a light weight xml database engine. Allowing for very powerful query and searching.

Download it from the site

Create a new Database and select the Packages folder. Make sure to tick skip corrupt files as there is 1 file it is not well formatted xml.


Take a few minutes


Screenshot below gets all the developer documentation on the tables.


Another example count the methods and the their name.


Big thanks to Peter Villadsen’s session at the recent tech conference.

Mining the Metadata and Authoring X++ Best Practice Rules in Microsoft Dynamics AX

I copied his queries from the video to get started (above two screenshots) but I already started experimenting with different things we can get out of the files.


Palle Agermark said...

Just what I needed for something this monday. Thanks.

Unknown said...

I'd like to add my thanks too, as I have found this technique to be very useful on a number of occasions. For example, if you want to get the KB numbers of the hotfixes applied to an AX 7 code base, you can use the following query in BaseX:

declare namespace d2p1="";
for $k in //KBNumbers/d2p1:string/text()
group by $k
order by $k ascending
return {$k}

Unknown said...

I see that the XML tags I had around {$k} have ben stripped out of my comment above. If you just want a list of KB numbers, remove the braces, or if you want the number wrapped in an XML tag, just enclose the expression in braces with the appropriate opening and closing tags.

Munib Ahmed said...

Gold. Nice one Martin.
Thanks for that.