AX – D365FO – Save previously used Query in a RunBaseBacth class

If yoou want to save last used Query on a RunBaseBatch class just set TRUE the QueryRun.saveUserSetup() method like show in the example below

public QueryRun queryRun()
   return gQueryRun;

public void initQueryRun()
   Query                               query = new Query();
   QueryBuildDataSource                inventJournalTableDS;
   QueryBuildRange                     inventJournalStatus;
   QueryBuildRange                     inventJournalStatusRange;
   inventJournalTableDS = query.addDataSource(tableNum(InventJournalTable));
   inventJournalStatus  = inventJournalTableDS.addRange(fieldNum(InventJournalTable, Posted));

   inventJournalStatus = inventJournalTableDS.addRange(fieldNum(InventJournalTable, JournalId));

   gQueryRun = new QueryRun(query);

This code will enable the “Previously used Query” option while opening the Select Form dialog like shown below

Leave a Reply

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

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

Facebook photo

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

Connecting to %s