Tuesday, March 19, 2013

Get the element name of an AX2012 Report from the preview

This is going to be a short post, but hopefully it will help someone still.

One of the essential tasks when delivering an Dynamics AX solution to a customer will always be report customization. There are more than one thousand SSRS reports deliveres with Dynamics AX out of the box. I would say it is closed to guaranteed the customer wants some of them adjusted.

With the release of AX 2012 R2, more of the central reports are now split up into new reports dependent on various configurations being active or not. So what report is run can be a result of license, configuration or simply the state of the entity you are trying to report. This often results in frustration for the developer or consultant who is trying to figure out what exact SSRS Report element is actually being used. You don't want to spend time changing the wrong layouts.

The solution is actually very simple. You could even share this with the super user when asked what exact report is bugging them.

While in the preview of a SSRS Report, click the Save-button and choose PDF (other formats works as well):



Have the consultant or super user note down the suggested file name. This will be the name of the element within the AOT. After the dot, you will have the name of the design.


In order to figure out why one layout is chosen over another, you will still have to step through the code, but you know an easy way to find the correct Report element name.

UPDATE:
I realize this does not always work as intended. Some reports in some languages will rather suggest the title of the report as filename.

In those cases, you want to do what Lurker so kindly suggests in the comment below.

"\Forms\SrsReportViewer\Methods\init add a breakpoint
In the call stack open Classes\SrsReportRunController
this.reportname will have the report name and design."

Monday, March 11, 2013

Free Editor Extensions for AX2012

The code editor in AX2012 is based on the same editor as Visual Studio. Not many developers know the editor actually allows developers to extend the functionality of the editor. My preferred extension for Visual Studio is ReSharper from Jetbrains, but unfortunately it would not be possible to have it installed in AX2012. But there are some freely available Extensions at CodePlex, serving as an example of how we can extend the editor in AX2012. This neat project is released by José Antonio Estevan Estevan.

The latest release supports three improvements:
  • Highlight the brackets when the cursor is right in front or right after, giving you visual aid where the section starts and ends.
  • Highlight the current word, giving you visual aid on where this word is used in your code.
  • Collapse and un-collapse sections wrapped with {- and }-brackets.
Head over to José's blog and read more about the project he has shared with us.

Installing the Extensions is super easy. Just download the latest release, unpack the dlls and drop them in the EditorComponents-folder under Client\bin. When the client starts, it will pick them up right away.



Support the project by adding suggestions for more suggestions. One thing I like with ReSharper is the ability to CTRL+Click a type to navigate directly to it. It would be cool to be able to do that in the AX2012 editor. Though, F12 does the trick pretty well.

If you do not get the extensions to work, you might want to make sure the downloaded zip file is not blocked  by the operating system.

Right-click the packed file and choose properties:

If you see the Unblock-button, then this zip file and all the executable elements within are marked as "dirty". This includes dll-files. Just Unblock, unzip and make sure the dll-files you copy to your EditorComponents-folder are "clean".

Tuesday, March 5, 2013

Compare models in two modelstores using Powershell

Imagine you have two modelstores, and inside these two modelstores there are several models installed.

Then imagine you want to compare those two modelstores and list out what models are installed in both or just one of them. You are also interested to see what models are installed in both but have a different number of elements or version number. Basically, you could compare any of the properties of a AX Model (Publisher, Layer, Signed, Description, etc). The only thing you would not be able to compare is the metadata of the elements within the model.

PowerShell to the rescue
Meet the Compare-Object command, or simply "compare". You know how you can get all the models in a modelstore, so lets get one collection from Modelstore A and compare it to a collection from Modelstore B.

Here is the PowerShell script:

import-module "C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1"

compare `
 -ReferenceObject (Get-AXModel -Config AX2012_Test | select name, version, elementcount) `
 -DifferenceObject (Get-AXModel -Config AX2012_Dev | select name, version, elementcount) `
 -PassThru -Property name, version, elementcount | where {$_.SideIndicator -eq "=>"} | sort name

Now you can change the code to fit your needs. You can remove the where clause (and the pipe in front) and just get a complete list. Play with it and compare modelstores. Each query is quick and painless.

Hope this helps someone.