·
1 min read

How to Specify Range Values on a Query in a AX SSRS Report

The steps below outline how to specify range values for a query that is used by an SSRS report and AX.

1.  In AX in the AOT model a query adding the tables you would like to specify as data sources.  For example, add the CustTable.

2.  To the data sources add your range fields.  Add the Currency and AccountNum fields as ranges.

3.  In VS create a new data method and in the code for the method instantiate a new DataTable.

 // Create a data table.

DataTable table = new DataTable();

4.  Create a Dictionary that contains the field names and their values.  The dictionary will get passed to the query.

IDictionary<string, object> myRanges = new Dictionary<string, object>();

myRanges.Add(“CustTable.Currency”, “USD”);

myRanges.Add(“CustTable.AccountNum”, “”);

5.  Execute the query passing the dictionary to the query as a parameter.

 

// Dynamics AX. Select all the fields from the query.

table = AxQuery.ExecuteQuery(“select * from CustTableExampleQuery”, myRanges);

6.  In the report moxl create a new data set.

7.  Build your solution.

8.  In the property sheet for the new data set change the Data Source Type to Business Logic and change the Query to the name of your data method.

9.  Add a design to your report and specify a layout type for it.

10.  Drag-and-drop the fields from your data set to the Data node of your design’s layout.

11.  Right-click on the report and choose Preview.