Create RunbaseBatch Class with Query window selection in Ax 2009,Ax 2012

Step 1: Create a runbasebatch class with all the needed methods

Step 2: Override the initParmDefault() method

public void initParmDefault()
{
Query query = new Query();
QueryBuildRange queryBuildRange;
QueryBuildDataSource queryBuildDataSource;
;
// query.addDataSource(tablenum(CustInvoiceJour));
queryBuildDataSource=query.addDataSource(tableNum(CustInvoiceJour)); //Add Query
queryBuildRange=queryBuildDataSource.addRange(FieldNum(CustInvoiceJour,OrderAccount));
queryrun = new SysQueryRun(query);

super();
}

QueryRun queryrun()
{
return queryrun;
}

Step 3: In Run method you can apply your logic

public void run()
{
;
queryRun = this.queryRun();
queryRun.query().dataSourceNo(1).addRange(fieldnum(CustInvoiceJour,InvoiceDate)).value(queryValue(fromDate)+ ‘..’+ queryValue(toDate));
while(queryRun.next())
{
custInvoiceJour = queryRun.get(tablenum(CustInvoiceJour));
info(strfmt(“%1,%2”,custInvoiceJour.InvoiceId,custInvoiceJour.InvoiceDate));

}
}

BatchwithQuery

Advertisements

2 comments on “Create RunbaseBatch Class with Query window selection in Ax 2009,Ax 2012

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s