Tuesday, 11 April 2017

Simple x++ query with enum value range

static void queryEnumValue(Args _args)
{
    Query                   query;
    QueryRun                queryrun;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    PurchTable              purchTable;
    ;
   
    query = new Query();
   
    qbds = query.addDataSource(tableNum(PurchTable));
    qbds.addSortField(fieldNum(PurchTable, PurchId), SortOrder::Ascending);
    qbr     = qbds.addRange(fieldNum(PurchTable, PurchStatus));
   
    qbr.value(enum2str(PurchStatus::Received));
   
    queryrun = new QueryRun(query);
   
    while(queryrun.next())
    {
        purchTable = queryrun.get(tableNum(PurchTable));
       
        info(strFmt("%1", purchTable.PurchId));
    }
}

No comments:

Post a Comment