Search code examples
pdfaxaptax++dynamics-ax-2009

AX2009 "DateFormat" of utcDateTime changes when printed to PDF from AX report


I have been tasked with changing the format in which the date is shown in a reporting using the a utcDateTime field.

Example

To change date from "5/4/2015" to "4-May-15".

I have changed the field control properties in the report setting DateFormat:DMY, DateSeparator: --, DateYear: TwoDigits, DateMonth:Short name (first three letters).

This gives me the desired result when I open the report using AX but when I printed the report to a PDF the date format has changed back to the default setting(5/4/2015). However, it doesn't occur when printed to a XPS but my company requires PDF. Also, I have tried changing the properties of the EDT and Field in the table with no luck. This only occurs with utcDateTime datatype, not date datatype. How do I get the format I require on a PDF


Solution

  • The output to PDF is controlled by the PDFViewer class and for date/time fields is done in the writeDateTime method. it calls the system class method OutputDateTimeField.formatValue to do the formatting.

    You are free to roll on your own formatting in the writeDateTime method.