Saturday, February 15, 2014

Query Examples

// Query Examples


static void Query (Args _args)
{
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
SalesTable SalesTable;
query = new Query();

qbds = query.addDataSource(TableNum (SalesTable));

qbr = qbds.addRange(FieldNum (SalesTable,CustAccount));


qbr.value ('3003');

qbds.addSortField (FieldNum(SalesTable,SalesId));

queryRun = new QueryRun(query);


while (queryRun.next())
{

SalesTable = queryRun.get(tableNum(SalesTable));
print SalesTable.SalesId;

}
pause;
}



this.query().dataSourceTable(tablenum(SupplProduct)).addRange(fieldnum(SupplProduct, ShowOnReport)).value(QueryValue(NoYesCombo::Yes));

this.query().dataSourceTable(tablenum(AppointmentTable)).addRange(fieldnum(AppointmentTable, AppointmentId)).value(queryValue(activeAppoint.AppointmentId));
//
InventoryMangementOnhandView is ViewDatasource

 qbr = InventoryMangementOnhandView_ds.query().dataSourceNo(1).addRange(fieldNum(InventoryMangementOnhandView, DatePhysical));
    _qbr = InventoryMangementOnhandView_ds.query().dataSourceNo(1).addRange(fieldNum(InventoryMangementOnhandView, StatusReceipt));

//TO filter a date value to view data source

    qbr.value(strFmt("<%1", AsonDate.dateValue()));
// To filter a two enum value to view filtered date value to view datasource

    _qbr.value("1..2");

// Example range Value

 query = new Query();
        queryBuildDataSource = query.addDataSource(
            TableNum(CustTable));

        //----------- Range: AccountNum
        queryBuildRange = queryBuildDataSource.addRange(
            FieldNum(CustTable,AccountNum));
        queryBuildRange.value("4000..5000");


// Example with Explanation :
http://nathalie.gimenez.free.fr/DynamicsAX/DynamicsProg_queryrange.html

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...