Skip to main content

Posts

Showing posts from October, 2014

Returning a weeknumber from the standard calendar lookup form

A customer had a requirement for setting a week number for approximate delivery of purchased goods on shipment as an indication for the sales department of when the goods will be arriving. An integer field had been introduced on the table in question, and the customer wanted to be able to do a lookup in the standard calendar, but wanted a week number to be returned in stead of a date. I solved it like this: 1. For the field that was to contain ETAWeek there was an Extended Data Type called ETAWeek. On the EDT I put SysDateLookup in the FormHelp property 2. In the Form SysDateLookup I added a boolean variable in Classdeclaration. boolean calledFromIntegerField; 3. In the Form SysDateLookup - method init I added check to see if the SysDateLookup form was called from an integer form control. if (formRun.selectedControl() is FormIntControl)      calledFromIntegerField = true; 4.In the Form SysDateLookup - method closeSelect I added an extra else if block in the bottom to handle

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 pro