torsdag den 6. maj 2010

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 customer. :0)

2 kommentarer: