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)
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);
form = form.AOTnextSibling();
If successful, the code displays and Infolog window with the matching form name.