tirsdag den 7. oktober 2014

Dynamics AX 2012 R2 - Export to Excel command button

Today I had some trouble getting a normally simple thing to work in an AX form.

The form consists of to synchronized grids, and the user wanted an "Export to Excel" command button, so the active grid can be exported to Excel.

Normally this is very simple as you just need to add a command button to the form in the ActionPane somewhere and you're home free.

Not this time. It didn't work.

I googled and found this:

http://blogs.msdn.com/b/emeadaxsupport/archive/2009/09/07/how-does-the-export-to-excel-feature-work-under-the-hood.aspx

and put a breakpoint in the performPushAndFormatting method.
I didn't reach my breakpoint and Excel didn't even start.

Then I started to investigate the form.
Maybe the tables of the datasources of the form had some obscure property that needed tweaking, but no.

After pondering this for a while I found that the designer of the form had dropped a field group containing all the fields in the grid. Could that be the problem ?
Clearing the "DataGroup" property of the field group, allowed for dragging all the fields from the field group to the Grid node in the design, and presto, the Export button now worked like a charm.

Lesson learned. If you have a grid in your form, and you want to be able to use an "Export to Excel" command button, using field groups in the grid is a bad idea.

I experienced this on a Dynamics AX 2012 R2.

1 kommentar:

  1. There is a bug in the CU7 build where the kernel will only export to Excel fields directly on the grid, but not any fields in sub field groups. So in other words, if you have a grid with no underlying fields, but instead a field group containing the fields, the export to Excel will simply fail. This is a regression from previous versions, and you will need to update to a newer kernel version.

    Microsoft recommends always running on the latest kernel build (same major version, of course). The KB you want in order to fix the problem explained in this post is this one: KB2927378

    :-)

    SvarSlet