Hi guys, Today we see how to prompt a user with a query window in Ax 2012 using X++.
Run the below job.
static void sysQueryForm(Args _args)
{
Query query = new Query();
QueryRun queryRun;
CustomerTable customerTable;
query.addDataSource(tablenum(CustomerTable));
queryRun = new QueryRun(query);
if(queryRun.prompt())
{
while (queryRun.next())
{
customerTable = queryRun.get(tablenum(CustomerTable));
info(strfmt('Item – %1, Name – %2',customerTable.CustId, customerTable.CustName));
}
}
// Filter form data source
//if (! queryRun.prompt())
//{
//element.close();
//}
//
//CustomerTable_ds.query(queryRun.query());
}
We use SysQueryRun also
static void sysQueryForm(Args _args)
{
Query query = new Query();
CustomerTable customerTable;
SysQueryRun queryRunSys;
;
query.addDataSource(tablenum(CustomerTable));
queryRunSys = new SysQueryRun(query); // use first datasource from form query
queryRunSys.promptAllowAddDataSource(false);
if(queryRunSys.prompt())
{
while (queryRunSys.next())
{
customerTable = queryRunSys.get(tablenum(CustomerTable));
info(strfmt('Id – %1, Name – %2',customerTable.CustId, customerTable.CustName));
}
}
}
Keep Daxing!!
No comments:
Post a Comment