Search This Blog

Friday, September 16, 2011

ADD Query to AOT using X++

Sample X++ code used to Add the Query to AOT.
static void Krishh_addQueryToAOTUsingX++(Args _args)
{
    TreeNode                treeNode;
    Query                   query;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    str                     queryName = "MyQuery";
    #AOT
    ;
    treeNode = TreeNode::findNode(#QueriesPath);
    query = treeNode.AOTfindChild(queryName);
    if (!query)
    {
        treeNode.AOTadd(queryName);
        query = treeNode.AOTfindChild(queryName);
        qbds  = query.addDataSource(tablenum(Address));
        qbr   = qbds.addRange(fieldnum(Address,Name));
        query.AOTcompile(1);
        query.AOTsave();
    }
}

No comments:

Post a Comment

Thanks for visiting my blog,
I will reply for your comment within 48 hours.

Thanks,
krishna.