X++ Code to get the Ranges / Criteria from Query
Following Job illustrates how we can get the criteria / ranges specified by the user in the run-time Query criteria dialog.
static void Query_getRanges(Args _args)
{
Query query = new Query();
QueryRun queryRun;
QueryBuildDataSource qbd;
CustTable custTable;
QueryBuildRange range;
int cnt, i;
;
qbd = query.addDataSource(tablenum( CustTable));
queryRun = new QueryRun(query);
queryRun.prompt(); // To Prompt the dialog
cnt = queryRun.query(). dataSourceTable(tablenum( CustTable)).rangeCount();
//custGroup = this.query().dataSourceTable(QueryRun queryRun;
QueryBuildDataSource qbd;
CustTable custTable;
QueryBuildRange range;
int cnt, i;
;
qbd = query.addDataSource(tablenum(
queryRun = new QueryRun(query);
queryRun.prompt(); // To Prompt the dialog
cnt = queryRun.query().
for (i=1 ; i<=cnt; i++)
{
range = queryRun.query().
info(strfmt("Range Field %1, Value %2",range.AOTname(),range.
}
while (queryRun.next())
{
custTable = queryRun.get(tablenum(
info(strfmt("Customer %1, Name %2",custTable.AccountNum, custTable.Name));
}
}
Query to get data less than date
private Query buildQuery(Query _query,StartDate _date)
{
if(!tDate)
tDate = systemDateGet();
if(tDate)
{
_query.dataSourceTable( tablenum(DNemplContract)). addRange(fieldnum( DNemplContract, StartDate)).value(strFmt("<= %1", tDate));
// _query.dataSourceTable( tablenum(DNemplContract)). addRange(fieldnum( DNemplContract, //StartDate)).value( queryValue(tDate));
}
return _query;
}
{
if(!tDate)
tDate = systemDateGet();
if(tDate)
{
_query.dataSourceTable(
// _query.dataSourceTable(
}
return _query;
}
No comments:
Post a Comment