How to get used query values in Ax 2012

Hi all,

How can I get the previously used query values from the criteria?

Scenario is as follows,

I am working in a form customization, where I have two buttons. One for generating records in a grid and another button for just viewing the records.

The line records are getting generated while clicking the first button based on the query values.

Similarly I wants to generate the records for the second button without giving query selection window whereas system has to consider the already used query values.

Any suggestions? Thanks in advance.

Regards,

Faisal Raja J

You Can get an query values with the following expression.

DynamicParameter1= SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(CustTable)), fieldNum(CustTable, AccountNum)).value();

Regards

Shreedhara

Hi Shreedhara,

Using the suggested code, I can get only one field value from the query. But my question is different, I need the whole set of values which was selected previously.

Sometimes user may select values for 2 fields, sometimes 20 fields. I need the complete list of values selected in the criteria screen.

I hope you understand my requirement.

Regards,
Faisal Raja J

You can iterate through all ranges with rangeCount() and range() methods of the QueryBuildDataSource class (here is an example). Use a similar way for filters (queryFilterCount() and queryFilter() methods of the Query class).

Nevertheless it may be a wrong approach, depending on what you’re trying to achieve. If you want to execute the query again, don’t care about individual ranges. Instead, get the query (yourTable_ds.queryRun().query()), create a new QueryRun instance for it and iterate records with the next() method.

1 Like

Hi Martin,

Thanks for the reply. I believe this will resolve my issue however I tried some other ways and found an alternative solution for this.

I am using a container to pack the entire query for each record which can be used later while clicking the second button in my form.

Regards,

Faisal Raja J