AX 7: AOTgetPropertiesExt() always throwing CLR Exception


I have the following code in AX 7.

TreeNode treeNode;

TreeNode dsNode;

Struct propertyStruct;

treeNode = TreeNode::findNode(’\Forms\CustomJournalTableListPage\Data Sources’);

dsNode = treeNode.AOTfirstChild();

for (i = 1; i <= treeNode.AOTchildNodeCount(); i++)


str prop = dsNode.AOTgetProperties();

propertyStruct = dsNode.AOTgetPropertiesExt();


But i am always getting CLRException at AOTgetPropertiesExt() method that “Unable to cast object of type ‘System.String’ to type ‘System.Object[]’”.

If I compare the same code executing properly in AX 2012 with that of AX 7, the debugger shows me that in AX 2012, dsNode contains this → Query CustomJournalTableListPage object 430e3c90: SELECT FIRSTFAST * FROM CustomJournalTable_RU(CustomJournalTable). Whereas in AX 7, the dsNode contains this → Path: \Forms\CustomJournalTableListPage\Data Sources\CustomJournalTable. The treeNode in both AX 2012 and AX 7 contain this → Path: \Forms\CustomJournalTableListPage\Data Sources.

I guess methods like AOTfirstChild(), AOTgetpropertiesExt() etc are not working properly in AX 7.

Are these methods obsolete in AX 7? What are the alternate methods available in AX 7? Any clue?

It’s the same in my system. I suggest you report it to Microsoft; they’re the only ones who can tell you what’s intended and what’s just a bug.

I was told on Technical Conference that TreeNode API is still supported. On the other hand, properties work quite differently in AX 7, so there may be some exceptions.

Okay, it seems I have to report it to Microsoft.

Actually migrating from AX 2012 to AX7 is proving to be costly and laborious due to these aspects of X++ coding which worked well in AX 2012 but fails in AX7. I have also noticed that I get BP errors in AOTAdd() method saying that this method is obsolete in AX 7. If TreeNode API is still supported, then why I am getting these errors? No clue whatsoever that why is AOTgetPropertiesExt() throwing exception?

You don’t realize that AX 7 is not AX 2012. The architecture is completely different. Objects are stored in a different way, the whole execution runtime is gone etc. Pretending that it’s the same and trying to use the APIs for tree node manipulation without considering the differences is a bad idea. You should change your approach.

For example, AOTAdd() is deprecated because it doens’t make much sense in AX 7. You can easily add elements to a compiled DLL file.

Consider using new metadata API native to AX 7. Refer to your other thread, where I gave you an example.

I think that backward compatibilty is the only reason why these ugly APIs still exist and therefore they won’t be extended in future and they may be deprecated completely.

Nevertheless I can’t tell why the exception is thrown, because I don’t have access to Microsoft code (and I don’t have enough incentive to decompile it). That’s why you should talk to Microsoft.