Think Outside of the Box by Using X++ to Document Your Feature

By Bill Thompson | July 28, 2015

One of the extremely import tasks of development is to document what you have created.  This can include things such as comments within the code, but there are times you need more than that.   If you have created a rather complex piece of functionality (this could be anything from changing posting routine code to creating a custom module), you may be tasked with updating it at a later date (or you may inherit the code as well).  If this date is a couple of years AFTER the code has been deployed, will you remember what you were thinking when you designed the code?  Probably not.

Creating this type of documentation can be a bit of a tedious process, especially if you were not given a proper functional design document to create the feature.  Something to consider then is to create tools to help automate the process.

Dynamics AX has had the ability to work with Excel and Word for many versions, so why not utilize that functionality to create a document for your customization?  Utilize the built-in formatting commands to make the document have a standard format.  Here is some example code (it is not complete as it does not contain some macro definition code):

    Filename        fileName;
    str             myObject;
    UserInfo        userInfo;

    SysOperationProgress progress = new SysOperationProgress();

    // initialize globals
    modelName = _modelName;
    projName = _projName;
    enumsStarted = false;
    edtStarted = false;
    tablesStarted = false;

    progress.setCaption('Processing project …');

    fileName = 'c:\\' + _projName + '.doc';
    wordApplication = new COM(#wdProgId);
    wordDocuments = wordApplication.Documents();
    wordDocument = wordDocuments.add();

    wordStyles = wordDocument.styles();
    wordStyle = wordStyles.add('Titles');
    wordFont = wordStyle.font();'Calibri');

    select firstOnly name from userInfo where == curUserId();

    this.insertDocHeader('Project: ' + _projName + '\n',false,true);
    this.insertDocHeader('Model: ' + _modelName + '\n',false,true);
    this.insertDocHeader('Created by: ' + + ' (' + curUserId() + ')' + '\n',false,true);
    this.insertDocHeader('Date: ' + date2str(today(),213,2,DateSeparator::Slash,2,DateSeparator::Slash,4,DateFlags::FormatAll) + '\n',true,true);

This document will contain (in the very least in the object listing section) a list of objects that exist in the above mentioned project and the above mentioned Model.  Certain types of objects will have additional information.’);

OK, so that gives you a header, but what about the rest?  X++ has a construct called TreeNode().  You can use this to traverse your project, and update your document with any pertinent information you desire to pull from the metadata.   The dict* kernel classes can be a huge help in doing this as you can use those objects to pull property values, X++ code, etc. for your documentation.

A little snippet demonstrating part of this:

    // instantiate the dictClass object so we can process the class information
    dictClass = new SysDictClass(className2Id(_className));

    // dictTable instantiates successfully, so we can print out data
    if (dictClass)
        if (!classesStarted)
            classesStarted = true;
            this.insertHeading(int2str(sectionCounter) +'. Classes',1);


        classMethods = dictClass.methods(true,true,false);

        sEnum = classMethods.getEnumerator();
        while (sEnum.moveNext())
            dictMethod =    sEnum.current();
            methodName =;
            path        =   @'\Classes\' + + @'\' +;
            node        =   TreeNode::findNode(path);
            modelId     =   node.AOTgetProperty('Model');

            if (modelId == modelName)

Once your tool does the ‘heavy lifting’, you can go in and add additional pertinent information, thoughts, etc. on the specific feature.

It is not a trivial effort to create the toolset to do this, but once created, it can be re-used as a real time saving device.

Related Posts

Recommended Reading:

Manage U.S. Use Tax on Purchase Orders in Dynamics 365 Finance and Operations

  Managing sales tax requirements on your business purchase can be complicated, but Dynamics 365 Finance and Operations can help […]

Read the Article
5.19.22 Dynamics CRM

How to Write a Great Support Ticket in the Stoneridge Support Portal

Submitting a support ticket through the Stoneridge Support Portal is a quick and effective way to get assistance for any […]

Read the Article

Managing Your Business Through Uncertain Times Using Dynamics 365 Finance and Operations

  Dynamics 365 Finance and Operations (F&O) can help you make informed decisions on how to move your business forward. […]

Read the Article
5.13.22 Power Platform

Using Power BI Object Level Security

  The following article will demonstrate how to use Power BI Object Level Security to disable column data based on […]

Read the Article
5.12.22 Dynamics CRM

How to Use the Stoneridge Support Portal

Stoneridge Software’s support portal is an intuitive and useful function that makes it easy for you to access resources to […]

Read the Article
5.6.22 Dynamics GP

Dynamics GP Transaction Removal: Purchase Orders

  Are you having performance issues with Purchase Orders?  Do you find that there are old Purchase Orders on your […]

Read the Article
5.5.22 Dynamics GP

The Real Story about the Long-Term Future of Dynamics GP Support

I’ve seen a number of people put forward comment that Dynamics GP is going away and you have to get […]

Read the Article

New Features in Dynamics 365 Business Central 2022 Wave 1 Release – Financial Enhancements

The Dynamics 365 Businses Central 2022 Wave 1 Release has a lot of new and exciting features to help your […]

Read the Article
4.29.22 Dynamics GP

Dynamics GP Transaction Removals: Bank Reconciliation

  This is part 2 of a 3 part series on Dynamics GP Transaction Removals. These quick tips will hopefully […]

Read the Article

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!