Skip to main content

Posts

Toggling visibility of fields in a Grid in then preview Pane of a ListPage form using code

Tasked with hiding a specific field on the salesLine table in the sales order forms depending on the value of a field on SalesTable I searched for methods and came across: https://community.dynamics.com/ax/f/33/t/168729 I agree with the method of finding the field on the datasource of the formpart however a better method of making the field invisible is to reference formDataSource.object(fieldnum( , )).visible(true/false); instead of actually having to reference the form control. This will make the field visible/invisble anywhere in the form that the field of the datasource is used. In my case it was done like this: private void toggleintraCodeReturn() {     PartList    pl;     int pCount,partdsCount;     FormRun part;     boolean shown;     FormDataSource pfds;     FormDataSource  fds,partfds;     shown = this.currentSalesTable().CustMaterial == NoYes::Yes;     if (this.currentSalesTable().isFormDataSource())     {         fds = this.currentSalesTable().dataSour

Dynamics AX and project quotations in in .docx format

Just finished an assignment making a tool for Dynamics AX 2012R2 for creating project quotations in word, using AX data. The customer is an ETO company manufacturing production lines for slaugtherhouses. The tool should create a quotation file word document (.docx) using a word template (.dotx) prepared in a certain language. This would allow the customer to design the layout of the document in a easy and familiar way. The spec required the quotation to include Budgets with detailed information for each sub project of a main project. Budgets summarized for each sub project of a main project. Scope of supply, which contains short technical descriptions of the included units on the production lines (sub projects) Technical descriptions - a section of the document containing listing (only once for each unit/sub project) complete descriptions with pictures of each included unit The algorithm in short is this: Now the challenge was that for most itemids in the item forecast

Dynamics AX 2012 AOT add-in copying field list to clip board

Before Dynamics AX 2012 and the new editor which makes things a bit more Visual Studio like, we had some features in the AOT, that are gone now but I miss. I *might* have rambled and raved about this before ( http://gotdax.blogspot.dk/2012/03/dynamics-ax-2012-annoyances-for-old.html ) ;-). E.g. I miss the ability to mark all fields on a table in the AOT and simply copy them to code. In the olds days this could be done by simply marking the fields in AOT and dragging them to the editor window. I needed this and got fed up with having to type the field names my self so I made a little class with the main method: public static void main(Args _args) {     #AOT     DictTable   dt;     DictField   df;     int f,start,end;     Set s;     SetEnumerator se;     int tableno;     TextBuffer txtb = new TextBuffer();     str fieldNameList;     str tableName;     TreeNode treeNode;     str searchFor = 'Path: '+#TablesPath+#AOTDelimiter;     #define.FIELDS('\\Fields')     i

Calculating easter sunday in different ways

Once a long time ago I found an interesting document on the inter web, describing different calendar systems. From that I made a php-class for my website that can calculate easter sunday in the gregorian calendar. Then it is easy to calculate the rest of the danish holidays as they are offset according to easter sunday (except of course those that have a fixed date). I translated that class in to x++. You can find it here: https://onedrive.live.com/redir?resid=9B63D38F981FFD1B!39710&authkey=!ABv0yYPULV3ReIE&ithint=file%2cxpo Today I got talking with a colleague about calculating easter sunday so he mentioned that he had also made a version of the calculation: http://stackoverflow.com/questions/11048524/how-to-calculate-easter-sunday-in-x So of course - being a bit nerdy - we just *had* to check if the routines arrived at the same result. So we came up with: static void EasterTest(Args _args) {     Yr x;     date easter(Yr yr) // PÃ¥skedag / pÃ¥ske sønd

Forcing the Name field of a salesline to be synchronized to the purchline when using Drop shipment

Using non-stock items in the daily business can be handled in Dynamics AX 2012 by using Direct delivery. You can use the Button "Direct delivery" from a sales order you have created, to create a matching purchase order. However if you use the Name field on the salesline to describe the specifications of the item you want to the vendor, the standard functionality does create the matching purchase order lines so that the name of the originating sales line is also used on the sales lines. Direct deliveries are handled so that the inventory transactions of the salesline are marked against the purchline, so I wrote this small script to be able to get the hang of how to find the direct delivery purchaselines from the saleslines records of a sales order. static void Job235(Args _args) {     SalesLine   salesLine;     PurchLine   purchLine;     InventTransOriginSalesLine itosl;     InventTransOriginPurchLine itopl;     InventTrans it,it1;     InventTable iTbl;     InventHandl

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