Friday, 1 March 2013

Convert Ax Infolog to HTML - Utility class

The following is a helper class that will convert the Ax infolog into formatted HTML. The most obvious use of this would be for emailing detailed error information as part of a batch process or interface. It's designed to be easy to use, and able to be dropped into existing projects without too much trouble.

An example conversion follows - First the original Ax info-log window.

And the resulting HTML, displayed here in Internet Explorer:

One obvious difference is the missing dashed tree lines. If you want to extend it, the easiest way would be to define an image for the connection types (middle, start/end), then insert them as required instead of the non-breaking spaces that are currently used.

Example API usage (included in the main method of the class):

static void main(Args args)
    // The main method in this class is only used for testing.
    // The class is meant as an API only, and not a user-initiated
    // process.

    InfologToHtmlHelper         infologToHtml = new InfologToHtmlHelper();

    void _updateItem(int n)
        setPrefix(strFmt("Updating item %1",n));
        info("Item updated");

    void _execProcess()
        setPrefix("Executing process");
        error("Process aborted");


    _execProcess();     // Generate test info log messages


Note that image data is embedded into the HTML so no external links are necessary (see extra information about this below). This was tested in Ax 2012 but should work in all other versions. Feel free to use or modify the code as required, and add a comment below if you have any queries.

The options available when using the class are:

  • parmShowImages. Whether to include embedded images in the output. NB there may currently be an issue with embedded images when displayed in Outlook - See parmExternalImagePath below for an alternative method.
  • parmGenerateHeaderAndBody. Generate skeleton HEAD and BODY tags.
  • parmCutInfoLog. Remove entries from the Ax info-log after the HTML conversion has taken place.
  • parmTableStyle. CSS style applied to main TABLE element.
  • parmExternalImageUrlPath. Optional path to externally hosted images. This can be used if embedding image data directly into the HTML is causing issues (with Outlook in particular). If specified, this should be a path containing the files info.png, warning.png, document.png, error.png, warning.png. These images can be downloaded as a ZIP file.
  • parmColourText. This will show warning/error text in orange or red, and may be useful when rendering without images to differentiate between important/non-important messages.