Notifications
Announcements
No record found.
Hello Every One,
Is it possible to find a node under AOT ? (eg: Queries/Data sources/datasource1/datasource2).
As mentioned in the above example Under queries I have Data sources again data sources inside data sources and so on. Now I would like to find data source node using it's name . Either it may be direct node or child or grand child ...
Thanks,Phani
You can use TreeNode::findNode
TreeNode::findNode("\\Forms\\Address\\Data Sources\\Address\\Methods\\delete");
Hi Ergün Şahin,
My code should be generic like under Address form there is a data source and again inside one more data source . so just passing a data source name
is it possible to find the data source node.it can be present in parent level, child or grand child level. I don't want to point directly as you mentioned above. if it is possible to search be data source name that would help.
Thanks,
Phani
You have two main options. Either you'll use generic reflections APIs, such as TreeNode (TreeNodeIterator etc.) or SysModel* tables.
Or, in this particular case, you can use methods of FormRun and related classes. For example:
FormDataSource formDataSource; int i; for (i = 1; i <= formRun.dataSourceCount(); i ) { formDataSource = _formRun.dataSource(i); if (formDataSource.name() == xyz) { ... } }
Hi Martin,
Thanks for you reply,
Is the above applicable also for other AOT nodes like Queries or is it bit different?
Which of the things mentioned above do you mean?
If you want to see all the objects, it is possible to write a common structure that goes around the tree, but the code will visit the nodes that you are not interested in.If you want something more targeted, you need to play with codes. For example, below I wrote a code that browses the datasources under Query. It is possible to write similar things.
static void getQueryDataSourceNames(Args _args) { #AOT TreeNode rootObjTreeNode; void getNode(TreeNode _objTreeNode) { TreeNode objTreeNode = _objTreeNode; objTreeNode = objTreeNode.AOTfirstChild(); while (objTreeNode) { if(objTreeNode.treeNodeName() == "Data Sources") { objTreeNode = objTreeNode.AOTfirstChild(); if(objTreeNode) { info(objTreeNode.treeNodeName()); getNode(objTreeNode); } else return; } objTreeNode = objTreeNode.AOTnextSibling(); } } ; rootObjTreeNode = TreeNode::findNode(#QueriesPath "\\" queryStr(custAutoSettlement)); if(rootObjTreeNode) { getNode(rootObjTreeNode); } }
For Form DataSouce
static void getFormDataSourceNames(Args _args) { #AOT TreeNode rootObjTreeNode; void getNode(TreeNode _objTreeNode) { TreeNode objTreeNode = _objTreeNode; TreeNode objTreeNodeTmp; objTreeNode = objTreeNode.AOTfirstChild(); while (objTreeNode) { if(objTreeNode.treeNodeName() == "Data Sources") { getNode(objTreeNode); } if(objTreeNode.AOTparent() && objTreeNode.AOTparent().treeNodeName() == "Data Sources") { info(objTreeNode.treeNodeName()); } objTreeNode = objTreeNode.AOTnextSibling(); } } ; //rootObjTreeNode = TreeNode::findNode(#QueriesPath "\\" queryStr(custAutoSettlement)); rootObjTreeNode = TreeNode::findNode(#FormsPath "\\" formStr(CustBillingCode)); if(rootObjTreeNode) { getNode(rootObjTreeNode); } }
Thinking about it, there is no need to hesitate the loop as long as we don't print to the screen.I've written something more general below. The code is returning all the nodes. I just printed out dataSource and relations but you can see the whole tree if you open the closed info
static void getNodeNames(Args _args) { #AOT TreeNode rootObjTreeNode; void getNode(TreeNode _objTreeNode) { TreeNode objTreeNode = _objTreeNode; TreeNode objTreeNodeTmp; objTreeNode = objTreeNode.AOTfirstChild(); while (objTreeNode) { if(objTreeNode.AOTparent() && objTreeNode.AOTparent().treeNodeName() == "Data Sources") { info("------DATASOURCENAME------" objTreeNode.treeNodeName()); info(objTreeNode.treeNodePath()); } if(objTreeNode.AOTparent() && objTreeNode.AOTparent().treeNodeName() == "Relations") { info("------Relations------" objTreeNode.treeNodeName()); } //all object info //info(objTreeNode.treeNodeName()); if(objTreeNode.AOTfirstChild())//objTreeNode.treeNodeName() == "Data Sources") { getNode(objTreeNode); } objTreeNode = objTreeNode.AOTnextSibling(); } } ; //rootObjTreeNode = TreeNode::findNode(#QueriesPath "\\" queryStr(custAutoSettlement)); //rootObjTreeNode = TreeNode::findNode(#FormsPath "\\" formStr(CustBillingCode)); rootObjTreeNode = TreeNode::findNode(#ViewsPath "\\VendorView" ); if(rootObjTreeNode) { getNode(rootObjTreeNode); } }
Hi
If you could query the Dynamics AX Model Database to find a string across all objects? Well, using the simple SQL Query below, you can. Here’s how to search X code using Dynamics AX model database:
SELECT RootHandle.Name RootElementName, ElementHandle.Name ElementName, ElementTypes.ElementTypeName Type, CAST(Sources.SourceText AS nvarchar(MAX)) SourceText FROM Sources Sources JOIN ModelElement ElementHandle ON Sources.SourceHandle = ElementHandle.ElementHandle JOIN ModelElement RootHandle ON RootHandle.ElementHandle = ElementHandle.RootHandle JOIN ElementTypes ElementTypes ON ElementTypes.ElementType = ElementHandle.ElementType WHERE CAST(Sources.SourceText AS nvarchar(MAX)) LIKE '%h.karimi%'
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 503 Most Valuable Professional
André Arnaud de Cal... 434 Super User 2025 Season 2
BillurSamdancioglu 278 Most Valuable Professional