Thursday, October 16, 2014

Query Example2 In Ax 2012

Query Example In Ax 2012

static void CookBookEx25(Args _args)
{
    Query                           query;
    QueryRun                        queryRun;
    QueryBuildDataSource            qbds1;
    QueryBuildDataSource            qbds2;
    QueryBuildRange                 qbr1;
    QueryBuildRange                 qbr2;
    ProjTable                       projTable;
    ;
 
    query = new Query();
    qbds1 = query.addDataSource(tableNum(projTable));
    qbds1.addSortField(fieldNum(projTable,Name),SortOrder::Ascending);
    qbr1 = qbds1.addRange(fieldNum(projTable,Type));
    qbr1.value(queryValue(projType::FixedPrice));
 
    qbr2 = qbds1.addRange(fieldNum(projTable,ProjId));
    qbr2.value(queryValue('2') + '*');
    qbds2 = qbds1.addDataSource(tableNum(ProjEmplTrans));
    qbds2.relations(true);
    qbds2.joinMode(JoinMode::ExistsJoin);
    queryRun = new QueryRun(query);
    while (queryRun.next())
    {
            projTable = queryRun.get(tableNum(ProjTable));
            info(strFmt(            "%1, %2, %3",
            projTable.ProjId,
            projTable.Name,
            projTable.Type));
    }
}

No comments:

Post a Comment