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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: