web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Dynamics 365 Vs Me / Open any object from code e...

Open any object from code editor to in AOT node(Editor script)

Deepak Agarwal Profile Picture Deepak Agarwal 8,585

Open any object from code editor to in AOT node(Editor script)

I have posted a editor script method earlier that can open and browse table for code editor.using below code developer will have ease of opening any object from AX code editor to AOT node.


TO USE THIS CODE COPY AND PASTE THE METHOD IN EDITOR SCRIPT CLASS


void AX_OpenInAOT(Editor e)
{
#AOT
TreeNode treeNode;
FreeText selectedLine;
str 1 curSymbol;
int iCopyFrom;
int iCopyTo;
Set selectedNodesSet = new Set(Types::Class);
SetIterator setIterator;
Map map;
void add2Set(TreeNodePath _path)
{
;
treeNode = TreeNode::findNode(_path + #AOTRootPath + selectedLine);
if (treeNode)
selectedNodesSet.add(treeNode);
}
;
if (e.markMode() != MarkMode::NoMark && e.selectionStartCol() != e.selectionEndCol())
{
selectedLine = strLRTrim(subStr(e.currentLine(), e.selectionStartCol(), e.selectionEndCol() - e.selectionStartCol()));
}
else
{
selectedLine = e.currentLine();
for (iCopyFrom = e.columnNo()+1; iCopyFrom >= 0; iCopyFrom--)
{
curSymbol = subStr(selectedLine, iCopyFrom, 1);
if (!strAlpha(curSymbol))
break;
}
for (iCopyTo = e.columnNo()+1; iCopyTo <= strLen(selectedLine); iCopyTo++) { curSymbol = subStr(selectedLine, iCopyTo, 1); if (!strAlpha(curSymbol)) break; } selectedLine = (iCopyFrom <> 0)
{
setIterator = new SetIterator(selectedNodesSet);
setIterator.begin();
if (selectedNodesSet.elements() == 1)
{
treeNode = setIterator.value();
}
else
{
map = new Map(Types::String, Types::String);
while (setIterator.more ())
{
treeNode = setIterator.value();
map.insert(treeNode.treeNodePath(), treeNode.AOTparent().treeNodeName());
setIterator.next();
}
treeNode = TreeNode::findNode(pickList(map, "Location", "Select element type"));
}
if (treeNode && treeNode.treeNodePath() != TreeNode::rootNode().treeNodePath())
{
if (SysTreeNode::hasSource(treeNode))
{
if (treeNode.AOTparent().treeNodePath() == #macrosPath && subStr(e.currentLine(), e.selectionStartCol () - 1, 1) != '#')
return;
treeNode.AOTedit();
}
else
{
treeNode.AOTnewWindow();
}
}
}
}
}



-Harry

This was originally posted here.

Comments

*This post is locked for comments