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);
   gQueryRun.saveUserSetup(true);
}

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:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s