Skip to main content

Posts

Showing posts from November, 2010

AX - Import flat file job

I use this quite often. When I want a quick job to import a text file. static void ImportFileWithDialog(Args _args) { AsciiIO asciiIO; Filename filename; NoYesId skipFirstLine; Container line; Dialog dialog; DialogField dialogFileName, dialogSkipFirstLine; ; dialog = new Dialog("Import file"); dialogFileName = dialog.addField(typeid(Filenameopen), "File name"); dialogSkipFirstLine = dialog.addField(typeid(NoYesId), "Skip first line"); dialog.run(); if (dialog.run()) { filename = dialogFileName.value(); skipFirstLine = dialogSkipFirstLine.value(); } asciiIO = new AsciiIO(filename, 'R'); if (!asciiIO || asciiIO.status() != IO_Status::Ok ) { throw error (strfmt("@SYS19312",filename)); } ttsbegin; asciiIO.inRecordDelimiter('\r\n'); asciiIO.inFieldDelimiter(',')

AX - Table Maps

Maps in AX allow you to wrap tables at runtime. In other words, they allow you to map multiple table fields and share methods. One of the more popular ones is the AddressMap. The concept of Maps are great in AX but can be confusing at times. Check the msdn article: http://msdn.microsoft.com/en-us/library/bb278211.aspx One of the gotchas that experienced developers know about is. IntelliSense wont show the map. You have to type it in. custTable.AddressMap::formatAddress(); ie. [table].[map name]::[method to call]