Tuesday, July 5, 2011

To build a LIKE query in AX 2009

Hi,

to build a QueryRun object same as LIKE SQL query.

void createQuery()
{
    Query query = new Query();
    QueryRun queryRun;
    BOMTable bt;
    InventTable it;
    BOMId bomId;
    ;
    it = InventTable::find('ELB002');
    query.addDataSource(tableNum(BOMTable)).addRange(fieldNum(BOMTable, BOMId)).value(strfmt("%1-*",it.ItemId));
    queryRun = new QueryRun(query);
   
    bomId = strfmt("%1-%2",it.ItemId, SysQuery::countTotal(queryRun)+1);
    info(bomId);
}

Also review for more details QueryRanges

Hope it helps.

Thanks,
/Ashlesh

No comments:

Post a Comment