Axaptapedia is now maintained by AgileCadence For more information please click here.
Editor scripts OpenInAOT
From Axaptapedia
Description[edit]
- This is a nice script that will be very helpful to beginners for studying the Axapta objects. It will also drastically increase the development speed, because you won't have to search for objects in AOT every time.
- It also provides the overview of System Kernel objects that are not present in the AOT.
- System functions can also be looked up.
- In case there are more than one object with the selected name, a listview with the possible choices is shown, where the developer can select the needed object type.
- To lookup an object in AOT you can highlight the object name in the editor or simply put the cursor somewhere in the middle of its name.
Dynamics AX versions[edit]
Has been tested on Dynamics AX 3.0 SP3, Dynamics AX 3.0 SP5 KR2, Dynamics AX 4.0 SP1, Dynamics AX 2009 SP1 RU-2
Code[edit]
Simply create a new method in class Editor Scripts and paste the following code in it. <xpp>//<Editor_Scripts_OpenInAOT_ikash date=2006-12-01 txt='a script to open the selected object in AOT'> void addIns_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) && curSymbol != '_') break; } for (iCopyTo = e.columnNo()+1; iCopyTo <= strLen(selectedLine); iCopyTo++) { curSymbol = subStr(selectedLine, iCopyTo, 1); if (!strAlpha(curSymbol) && curSymbol != '_') break; } selectedLine = (iCopyFrom < iCopyTo) ? subStr(selectedLine, iCopyFrom + 1, iCopyTo - iCopyFrom - 1) : ; }
if (selectedLine) { add2Set(#ExtendedDataTypesPath); add2Set(#BaseEnumsPath); add2Set(#TablesPath); add2Set(#ClassesPath); add2Set(#MacrosPath);
if (selectedNodesSet.elements() == 0) { add2Set(#SystemFunctionsPath); add2Set(#SystemTablesPath); add2Set(#SystemTypesPath); add2Set(#SystemEnumsPath); add2Set(#SystemClassesPath); add2Set(#ClassesPath + #AOTRootPath + classStr(Global)); }
if (selectedNodesSet.elements() > 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(); } } } }
}</xpp>
Extensions[edit]
- To add more AOT nodes into the search, simply add the following line after the comment:
<xpp>
//The main elementTypes - can be extended add2Set("\\Path to the parent object in AOT");
</xpp>
- You can always modify the actions which you want performed with the found objects.
- They are divided into 2 branches - the SystemDocumentation nodes and the AOT nodes.
- At the moment the system documentation objects are opened in a new window and opened in the browser (the help file is shown) and the AOT objects are opened in a new window and the property sheet for the selected object is opened.