Wednesday, 9 December 2015

How to add/ set Multiple Enum values in a query Range in X++ in AX 2012.?

 Here, we will discuss that how to setup range for multiple Enum values/ elements. for this we need to call query datasource first then pass the query range. follow as mentioned below:

Method-01: Datasource init()

public void init()
{

Query query;
super();

query = ProdTable_ds.query();
qbds = query.dataSourceTable(tableNum(ProdTable));

qbr = qbds.addRange(fieldNum(ProdTable, ProdStatus));

}

Method-02: Datasource executeQuery()


public void executeQuery()
{
//qbr.value(SysQuery::valueNot(ProdStatus::ReportedFinished));

qbr.value(strFmt('%1,%2,%3,%4,%5', enum2str(ProdStatus::Created),

enum2str(ProdStatus::CostEstimated),

enum2str(ProdStatus::Scheduled),

enum2str(ProdStatus::Released),

enum2str(ProdStatus::StartedUp)));
 
super();

} 


Note:

qbr.value(strfmt("%1,%2", Date2StrXpp(fromDate), Date2StrXpp(todate)));
 

OR

qbds.addRange(fieldNum(EIRTenderRecordTable, Status))
        .value(queryValue(EIRStatus::Active));
qbds.addRange(fieldNum(EIRTenderRecordTable, StartDate))
        .value(SysQuery::range(_requisitionDate, dateNull()));
qbds.addRange(fieldNum(EIRTenderRecordTable, EndDate))
        .value(SysQuery::range(dateNull(), _requisitionDate)); 

Not empty records:

qbds.addRange(fieldnum(custtable,name)).value(sysquery::valueNotEmptyString()) ;

Empty records:

qbds.addRange(fieldnum(custtable,name)).value(sysquery::valueEmptyString()) ;

Records are not equal 10000:

qbds.addRange(fieldnum(custtable,accountnum)).value(sysquery::valueNot(“10000”) ) ;

Ranges:

qbds.addRange(fieldnum(custtable,accountnum)).value(queryrange(“1″,”10000”) ) ;

Enum:

qbds.addRange(fieldnum(B_RMARequestTable, RefType)).value(queryvalue(B_RMAReqRefType::RepairJournal));

Happy DAXing.....