Queries in Dynamics Ax

Reference: https://msdn.microsoft.com/EN-US/library/bb278121.aspx
The Application Object Tree (AOT) provides a graphical interface for creating queries. These are known as static queries. When a query is created using the AOT, the SysQuery and SysQueryRun classes are used behind the scenes.

In Microsoft Dynamics AX, static queries are located in the Queries node and contain the following primary sub-nodes:
  • Methods
  • Data Sources
  • Dependent Objects
  • Composite Query

Methods

The Methods node displays all the methods available from a query. In this node you can add a new method to a query. You can also override methods on the QueryRun system class and add your own code to class methods inherited from the QueryRun class. Only new methods and overridden methods appear in the Queries node except for the classDeclaration method which is always present.
To add a new method:
  1. Navigate to the Queries node in the AOT, right-click the node and, then select New Method.
  2. Enter your code in the Editor window and save your changes.
To override a method:
  1. Navigate to the Queries node in the AOT, right-click the node, and then select Override Method.
  2. Select the method that you want to override.
  3. Enter your code in the Editor window and save your changes.
Methods that have been overridden display an icon with an arrow

Data Sources

The Data Sources node contains a hierarchy of data sources from which the query gets its data. A query data source can be a table, map, or view.
Data sources can be embedded inside each other (nested). A nested data source is referred to as a child data source of the parent data source. A child data source has all the standard data source elements, and it also contains a relations element. The relation is used to define how the parent data source is related to the child data source. Whenever a record in the parent data source is selected, the child records are selected based on the relation that is defined and any record ranges that are specified.

Create a Query for a Single Data Source

  1. In the AOT, right-click Queries, and then click New Query.
  2. Right-click Data Dictionary, and then click Open New Window.
  3. Drag a table, map, or view from the second window to the Data Sources node under the new query in the first window. All the fields in the data source are included in the query by default.
  4. To remove fields and add fields, do the following:
    1. Click Data Sources, click the data source that you added in step 3, right-click Fields, and then click Properties.
    2. Set the Dynamic property to No.
    3. Expand the Fields node, locate the field that you want to delete, right-click the field, and then click Delete.
    4. Right-click the Fields node, and then click New > Field.
    5. Right-click the new field, click Properties, and select the field that you want to add in the Field property list.
  5. To override a QueryRun Class method, right-click the Methods node, click Override Method, and then click a method.
  6. Right-click the new query, click Properties, and then modify the properties as needed.
  7. Save the new query.

  Dependent Objects

The Dependent Objects node contains a node for every AOT object that references the query, such as forms and reports. This shows you which objects are affected when you modify the query.

Composite Query
A query can be based on another query, as a mechanism for efficient reuse of the original query. You drop the original query onto this node, instead of onto the Data Sources node.



Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular posts from this blog

D365: SSRS Report Development/ Customization

D365: X++ code to add custom lookup on worker to show specific workers team workers only

Error message when you log on to a Microsoft Dynamics AX 4.0 client: "You are not a recognized user of Microsoft Dynamics AX"