what is map in axapta?

Can any one help to know MAPs in axapta? difference between table and maps as both are looking similar? what is the use of MAPPING node in maps and how can we use the map methods? eg. AddressMap in ax 2009

Hello Santhosh,

Maps define X++ elements that wrap table objects at run time. With a map, you associate a map field with a field in one or more tables. This enables you to use the same field name to access fields with different names but the same data type in different tables. Map methods enable you to create or modify methods that act on the map fields.

A table can be accessed through more than one map. Typically, if more than one map accesses the same table, each map accesses different subsets of fields in the table. Maps don’t define database objects and so they aren’t synchronized with the database.

The benefits of maps include:

Simplicity - maps provide a single interface to fields in multiple tables. This means that any object referencing the map field can be used against multiple tables without changing any field names.

Consistency - table fields with varying names can be accessed in code in a consistent manner. For example by using a map, fields named Zip in one table, ZipCode in another, and PostalCode in yet another table can all be accessed by the name ZipCode.

Code reuse - a map method enables you to add code that runs against the map fields. A single map method prevents the duplication of methods and code on each table.

An example of a map in Microsoft Dynamics AX is the Address map, which can be used to access fields in two tables (among others) called Address and CustVendTransportPointLine. This enables developers to use one Address map object to access common address fields and methods.

Map Elements: In Microsoft Dynamics AX, maps are located in the Application Object Tree (AOT) under the Data Dictionary\Maps node. Each map has four primary elements:

  • Fields

  • Field Groups

  • Mappings

  • Methods

Fields: The Fields node contains the map field elements. Each field must be the same data type as the field to which it’s associated. Use the ExtendedDataType property to specify the map field’s data type if the map field is associated with a table field that’s based on an extended data type.

Field Groups: The Field Groups node contains field groups that group together fields that logically belong together. Field groups in maps work the same way they do in tables. For more information about field groups, see Best Practices for Field Groups, Defining Field Groups, and How to: Create a Field Group.

Mappings: The Mappings node is where the map fields are associated with table fields. Directly under the Mappings node are the MappingTable objects. Each MappingTable object specifies a table that the map is associated with. Under the MappingTable object are the field mappings that associate a map field with a table field. If a field exists in the map with no associated field in a particular table just leave the MapFieldTo property blank.

Methods: This node displays all the methods available from a map. In this node you can add a new method or you can override methods on the xRecord kernel class and add your own code.

Map methods are useful because code that acts on the map fields can be encapsulated in a map method instead of being in multiple table methods. For example, the AddressMap has a formatAddress method that formats the address consistently whether the map references the Address table or the CustTable table.