Tuesday, 13 February 2018

Dynamic query creation in Ax2012

Dynamic query creation in Ax2012

Sub: Creating run time query in job

static void DynamicQuery(Args _args)
{
    
    // Author : Rajaram
    // Title : simple query creation  

    Query                               query;  
    QueryBuildDataSource   queryBuildDataSource;
    QueryBuildRange            queryBuildRang;
    QueryRun                        queryRun;
    SalesTable                       salesTable;
    ;


    query                   = new Query();// creating query instance 
    queryBuildDataSource    = query.addDataSource(tableNum(salesTable));// adding datasource in the query
    queryBuildRang          = queryBuildDataSource.addRange(fieldNum(salesTable,CustAccount));// set range 
    queryBuildRang.value("DE-001");// range value
    queryRun                = new QueryRun(query);// query run


    while(queryRun.next())
    {
       salesTable = queryRun.get(tableNum(salesTable));// geting records from table using query run 
       info(strFmt("%1 %2",salesTable.SalesId, salesTable.CustAccount));
    }
}

No comments:

Post a Comment

Step-by-Step Guide to Restore a SQL BACPAC File - Microsoft dynamics D365 Fin & Ops

 Restore steps for bacpac file in to SQL server - Microsoft dynamics D365 Fin & Ops. Log in to LCS and navigate to the asset library. On...