Create Query in AX via x++

Berikut adalah contoh script untuk membuat query pada ax via coding(x++).

Screenshot :

#AOT

treeNodeObj = TreeNode::findNode(#QueriesPath);
treeNodeObj = treeNodeObj.AOTfindChild(queryName);
if (treeNodeObj) {
treeNodeObj.AOTdelete();
}

treeNodeObj = TreeNode::findNode(#QueriesPath);
treeNodeObj.AOTadd(queryName);
queryObj = treeNodeObj.AOTfindChild(queryName);

qbds  = queryObj.addDataSource(tablenum(CustTable));
qbr   = qbds.addRange(fieldnum(CustTable, DlvMode));
qbr.value(“>10”);

queryObj.AOTcompile(1);
queryObj.AOTsave();

qr = new QueryRun(“TestQuery”);
while ( qr.next() )
{
xrecCustTable = qr.GetNo(1);
Global::info(strFmt(“%1 , %2”,
xrecCustTable.AccountNum, xrecCustTable.DlvMode));
}

treeNodeObj = TreeNode::findNode(#QueriesPath);
treeNodeObj = treeNodeObj.AOTfindChild(queryName);
treeNodeObj.AOTdelete();

 

Happy coding 🙂

Advertisements