Yesterday, miklenew from AxForum posted an editor script for AX 3.0 that opens a new AOT window with the object currently selected in the Editor, that works a little differently and also allows to open objects based on variable type. You can view the original post here.
Today I modified this code, extending it a bit and adding support for Dynamics AX 4.0 and Dynamics AX 2009 (For version 3.0 use the code posted on AxForum).
public void addIns_OpenInAOT(Editor e)
TreeNode treeNode = TreeNode::findNode(e.path());
Column nCol = e.columnNo() + 1;
Line nLine = e.currentLineNo() + 1;
xRefTmpReferences = xRefCreate::makeTmp(infolog.lastxRef());
select firstonly xRefTmpReferences
order by Column desc
where xRefTmpReferences.line == nLine &&
xRefTmpReferences.Column <= nCol;
treeNode = TreeNode::findNode(xRefTmpReferences.path());
As you can see, the code is very simple and utilizes the xReferences.
But the great thing about it is that updating the cross references is not required for this code to work, as it updates them on the fly for this specific AOT node.
I think this is a must have method for each application developer out there. :)