By default, Dynamics AX 2009 comes with nine default
inventory dimensions. (The user can define additional inventory
dimensions.) Dimensions describe the characteristics of items or item
lots. Item dimensions might include characteristics such as
configuration, model, and size. Item lots might have storage dimensions,
such as site, warehouse, location, or pallet, or they might be
identified by a serial number and batch number. The site dimension is
new in Dynamics AX 2009.
The following
customization scenario describes how to customize tables and classes
used by the inventory dimension feature to implement two new item
dimensions that describe a specific bicycle configuration: frame size
and wheel size. This description isn’t an exhaustive list of elements
that you must change; instead, it offers guidelines for finding the
elements necessary to customize the full implementation of a new
inventory dimension.
Creating New Dimension Types
When
implementing new inventory dimensions, your first task is to create
extended data types for each of the dimensions. Doing so provides the
following benefits:
- To apply the inventory dimensions to multiple tables, you define the type just once and then apply it to each table.
- The Label property, the HelpText
property, and a few constraints can be defined on the data type,
ensuring consistent behavior and appearance of fields of the same type.
- If
the type is declared as a parameter or a return type for a method, you
can declare variables of the type in X++ code to optimize IntelliSense
responsiveness and to improve the readability of the code.
This scenario defines a
table in which a field of the specific type is part of the primary key.
You can define the relationship to this table on the extended data type
and subsequently instruct the application runtime to provide lookups and
Go To The Main Table Form support.
In this example, you enter the Data Dictionary in the Application Object Tree (AOT) and create a BikeFrameSize extended data type and a BikeWheelSize extended data type. Table 1 lists the property settings that deviate from the default settings.
Table 1. BikeFrameSize and BikeWheelSize Property Settings
Property | BikeFrameSize | BikeWheelSize |
---|
Type | Real | Real |
Label | Frame size | Wheel size |
HelpText | Frame size in inches | Wheel size in inches |
AllowNegative | No | No |
ShowZero | No | No |
NoOfDecimals | 0 | 0 |
Figure 1 shows the property sheet for the BikeFrameSize extended data type, accessible by clicking Properties on the context menu for the type.
Next, create two tables, named BikeFrameSizeTable and BikeWheelSizeTable,
in which the frame and wheel sizes for each item can be stored. In
addition to the specific inventory dimension types, the tables also
contain an ItemId field and a Name field. The ItemId and dimension in each table constitute the table’s primary index.
Table 2 lists the BikeFrameSizeTable property settings that deviate from the default settings. (The property settings for BikeWheelSizeTable are identical except for the BikeWheelSize field and its extended property type.)
Table 2. Field Property Settings
Property | ItemId | BikeFrameSize | Name |
---|
Type | String | Real | String |
ExtendedDataType | ItemId | BikeFrameSize | Name |
Mandatory | Yes | Yes | No (default) |
AllowEdit | No | No | Yes (default) |
Create a unique index on both tables. For BikeFrameSizeTable, name the index FrameIdx and make it contain the ItemId field and the BikeFrameSize field. For BikeWheelSizeTable, name the index WheelIdx and make it contain the ItemId field and the BikeWheelSize field. Declare the indexes as the PrimaryIndex on the respective tables. In the AOT, the fields and the indexes appear as shown in Figure 2.
In addition to the fields and index shown in Figure 2,
you should also set properties in the tables for caching, form
references, and so on, and the table should contain field groups and
methods for checking the validity of the fields. The Microsoft
Dynamics AX 2009 software development kit (SDK) contains guidelines and
best practices for creating tables.
After you define the
tables, you should update the extended data types to reflect their
relationship to the individual tables, as shown in Figure 3.
This relationship
instructs the Dynamics AX runtime to provide lookup and Go To The Main
Table Form functionality when fields of these types appear on forms. The
application runtime uses the related table as the data source for the
lookup form and also to find the main table form from the FormRef property on the table. You must therefore create forms for the BikeFrameSizeTable and BikeWheelSizeTable tables and menu items to open the forms. These menu items are added to the FormRef properties on the corresponding tables. You could design the forms to mirror the form shown in Figure 4. See the Microsoft Dynamics AX 2009 SDK for general information on designing forms.