Skip to main content

Posts

Methods of opening a browser

Mental note to self: Ways of programmatically opening a browser with a webpage in x++: infolog.urllookup('http://www.fasor.dk'); This will open the standard browser. Or WinAPI::shellExecute('iexplore.exe','http://www.fasor.dk'); This specifically opens internetexplorer. The last method can also be used for starting up 3rd party applications from Axapta.

A quick way of dumping records of a table in an xml-file.

A quick way of of dumping table records into a xml-file is to use the kernel method xml, which is present on all instances of a tablebuffer. However, the xml produced by this method is NOT well-formed. Three problems exists: No header info for the xml-document is written No root node is written The data within tags are not html escaped When the xml-method is called a call to the GLOBAL class method XMLString method is made. With a little adjustment to this method we can make the XML data output wellformed. But first you must add this method to the GLOBAL class: public static str escapeHTMLChars(str _in) {     int x;     str out;     for(x=1;x<=strlen(_in);x++)     {         if ((char2num(_in,x) < 32) && (char2num(_in,x) > 126))         {             out += '&#'+num2str(char2num(_in,x),0,0,0,0)+';';         }         else         {             out += substr(_in,x,1);         }     }     return out; } And now back to the global::XMLString m

Outlook WTF ?

A quick None AX-related post regarding strange software behaviour. I was booking my wifes work in my calendar. She works nights right now at a hospital, and I needed this in my calendar, to be able to plan in project work for my studies. She works night shifts 7 days in a row starting tuesday evening ending monday morning the following week, and this every second week. I tried to book this using reoccurence, and got an extreme amount of hours. WTF? :0)

AliasFor property on a tablefield

Ever wonder what the AliasFor property on a table field is used for ? It is actually a pretty nifty little feature of the AX runtime. I was tasked with making a solution for the following problem: * Introduce a new field on the item table that can hold the EAN number of the item. * Enable the user to be able to type in either the item id OR the EAN number when searching for an item to put on e.g. a sales order line. * Make sure that the EAN number is shown in the look up lists This actually quite easy to do. First I created the EAN number field on the InventTable using a new extended datatype created for that purpose. Then I created a new index on the InventTable containing the new field. This of course makes for searching for EAN numbers effeciently, but it also makes the EAN number field appear in the lookup list. The final thing to do was to set the AliasFor property of the new EAN Number field to be an alias for ItemId, by assigning the value ItemId to the property. Now "magic

Dynanics AX - WTF ?

Try the following job in Dynamics AX: static void Job16(Args _args) {; info(conPeek(new HeapCheck().createAContainer(), 4)); } I've tested it in Dynamics AX 2009 and Axapta 3.0, so I guess it would work in Dynamics AX 4.0 also. Translated from danish the result reads: "Hi mum, heres comes a buffer" An AX easter egg. :) 2012.11.07 - Update: Just tried the same "fun" job in Dynamics AX 2012. It seems that the good people at Microsoft have been reviewing some of the old kernal functions, as the result of running the above mentioned is now: "buffer buffer buffer buffer". 2023.08.30 - Update: "buffer buffer buffer buffer" is still the boring result in D365. :)

Finding differences in code layers between installation

When working with customizations in Dynamics AX I consider it best practice to have several installations for the same customer. At a minimum you should have a development environment, a development test environment, a test environment besides the production environment that the customer runs in daily business. DEV. The development environment is for hacking away, developing and doing research and experiments. DEV TEST. The development test environment is for testing the customizations (inhouse QA) before releasing it to the customer for test. The transfer of customizations between DEV and DEV TEST is done by exporting and importing .xpo-files. TEST. The TEST environment is where the customer makes acceptance test of customizations. The transfer of code to the TEST enviroment is preferably done by copying layer (.aod)-files from the DEV TEST to the TEST, allowing for release/build control. If successive deliveries must be done, this can be again be done by exporting importing code AS L

Formatting real-controls i AX reports using x++ code

I was asked by a (danish) client if Dynamics AX could format amount fields according to lanaguage code of the customer. The problem arises as the danish format for amounts is: 999.999.999,99 That is thousand separators are the dot-sign and decimal separator is the comma-sign, and the english format is 999,999,999.99 That is thousand separators are the comma-sign and decimal separator is the dot-sign. Now the Ax client is able to run in several language of course, but this also imposes the regional settings on any reports printed. Thus if you run the AX client with danish language and prints an invoice for an english customer, all amounts will be printed using danish formatting. I wrote a small class that builds a list of all real-controls in a report. You can then feed it a langauge code and it will traverse the list of controls and format them accordingly. Thus we can now batch invoice customers and get invoices printed where amounts are formatted according to the language code of the