Freigeben über


Use X++ to Loop through the AOT

Recently, I had a need to loop through the Forms node in the AOT and find any form that had a particular property value. I've seen a lot of examples that show you how to locate nodes in the AOT by name, but not by a property value. So I thought I would share the code that I wrote for the task.

For a little background, when you press F1 on a form in AX, it brings up a help topic for that form. Each form is hooked up to help via the HTMLHelpTopic property (and the HTMLHelpFile property if you want to get precise). To find this property you need to open the form in the AOT and then navigate to the Design node.

 

Here's the code that loops through the forms.

static void FindFormInAOT(Args _args)

{

    #AOT

    Treenode formNode;

    Treenode form;

    Form actualForm;

    str HTMLHelpProperty;

    str formName;

    int i;

    int nodeCount;

    ;

    formNode = treenode::findNode(#FormsPath);

    // Count of all the forms.

    nodeCount = formNode.AOTchildNodeCount();

    form = formNode.AOTfirstChild();

 

    for (i=1; i<=nodeCount; ++i)

    {

        formName = form.AOTgetProperty("Name");

 

        actualForm = formNode.AOTfindChild(formName);

        // Get the HTMLHelpTopic property.

        HTMLHelpProperty = actualForm.design(0).hTMLHelpTopic();

        if (strScan(HTMLHelpProperty, "386c78e8-16c3-404f-aad2-d50248c26905", 1, strLen(HTMLHelpProperty))>1)

        {

            info("Form name is: " + formName);

            break;

        }

        form = form.AOTnextSibling();

    }

}

If successful, the code displays and Infolog window with the matching form name.

Comments

  • Anonymous
    July 04, 2011
    This is extremly fantastic and useful article. Thanks very much and appreciate your help!

  • Anonymous
    May 22, 2014
    The comment has been removed

  • Anonymous
    March 19, 2015
    @ RLP This code can be altered a bit to find MODIFIED objects in an specific layer using SysTreeNode::existsInLayer(treeNode, PUTYOURLAYERHERE), not only the forms, but the tables using #TablesPath or Classes using #ClassesPath. It is a great article, very useful. Thanks