Download Features of Microsoft Dynamics AX

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Database wikipedia , lookup

Microsoft Access wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Functional Database Model wikipedia , lookup

Ingres (database) wikipedia , lookup

Team Foundation Server wikipedia , lookup

Clusterpoint wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Relational model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Database model wikipedia , lookup

Transcript
CHAPTER 1: ARCHITECTURE
Introduction
Microsoft Dynamics AX 2012 is a customizable, multiple-language, and multiple-currency
Enterprise Resource Planning (ERP) solution. Microsoft Dynamics AX excels in:
•
•
•
•
Manufacturing.
E-business.
Wholesale.
Services industries.
Microsoft Dynamics AX is a completely integrated solution and is web-enabled and supports
Microsoft® SQL Server®. With customizable source code, the solution can be modified however
and whenever it is necessary.
Features of Microsoft Dynamics AX
Microsoft Dynamics AX is a unique and powerful solution that contains functional and
development environment features, which include the following:
•
Functional features
o Single database architecture is used for all companies in the organization.
o Highly integrated design between functional areas such as resource planning, sales, and
manufacturing.
o Dimension-based system for all modules.
o Advanced features such as Forecasting and Master Planning are available.
o Multi-currency and Multi-language capabilities.
•
Development environment features
o Microsoft Dynamics AX MorphX is an integrated development environment (IDE)
for developing in Microsoft Dynamics AX.
o Visual Studio is an alternative development environment for web, report and managed
code development.
o The Application Object Tree (AOT) provides a uniform and compact viewing repository.
o Drag-and-drop functionality is supported for many programming tasks.
o Projects help organize and track customized applications in Microsoft Dynamics AX.
Client Workspace
The client workspace is the standard rich client interface that an end-user uses. The workspace
consists of various components:
The Navigation pane is the menu on the left side of the screen that shows all of the modules the
current user has access to.
The content pane displays role centers, list pages and area pages.
•
Role centers display specific data, reports, alerts, and common tasks associated with a user's
role in the organization. The role center is displayed when an end-user opens the application
or goes to Home in the Navigation pane.
1
•
List pages display lists of data. They are optimized to view and search through a list of
records and act on information.
•
Area pages display all menu items relevant to the module selected in the Navigation pane.
They are grouped logically to make it easier for end-users to find what they need.
FIGURE. WORKSPACE
Architecture
Microsoft Dynamics AX has a three-tier architecture.
Three-Tier Architecture
Three-tier architecture is defined as having a separate database, server and client where:
•
•
•
The database stores the data.
The server runs the application business logic.
The client application allows users to connect to the server to access business logic and use
the data in the database.
In Microsoft Dynamics AX the three tiers include the following:
•
A SQL Server Database that houses the data entered into, and used by, the Microsoft
Dynamics AX application. It also houses the model store that contains the application
elements.
•
An Application Object Server (AOS) is a service that runs most of the business logic. This
runs continuously on a central server.
•
The Client application is the user interface through which an end-user accesses Microsoft
Dynamics AX. There are various clients available including the Microsoft Dynamics AX
rich client and Enterprise Portal.
2
FIGURE. THREE TIER ARCHITECTURE
Extended Architecture
Several other components of the Microsoft technology stack are used in a typical deployment.
Reports are delivered by SQL Reporting Services (SSRS). SSRS is a component included in
SQL Server.
Business Intelligence (BI) components such as Key Performance Indicators use Online
Analytical Processing (OLAP) cubes which are delivered by SQL Analysis Services (SSAS).
SSAS is a component included in SQL Server.
The Enterprise Portal and Role Pages are hosted in SharePoint. There are two versions of
SharePoint that can be used. Window SharePoint Foundation 2010 is a free download. Microsoft
SharePoint Server 2010 is a product that can be purchased to provide extended collaboration
and content management tools.
Integration to other applications or to third party organizations might require integration
solutions such as web services.
The following image describes a typical system architecture that includes other components of
the Microsoft technology stack.
3
FIGURE. EXTENDED ARCHITECTURE
SQL Server Databases
Microsoft Dynamics AX Database
The Microsoft Dynamics AX database is an Online Transactional Processing (OLTP) database that
stores all the business data in SQL tables.
This database also stores all of the metadata and application code in the Model Store.
Business Intelligence (BI) Databases
Some BI components of Microsoft Dynamics AX also require you to use SSRS and SSAS. The
SSAS database is replicated from the OLTP database in a database format that is optimized for fast
reporting and analysis.
Application Object Server
The Application Object Server (AOS) is the Microsoft Dynamics AX application server. The
AOS is where most of the business logic is executed. The AOS performs many tasks. Some of the
most important tasks include:
•
X++ runtime: It runs the X++ code which provides most of the business logic in
Microsoft Dynamics AX.
•
Security: It enforces security to manage access to data and functionality.
•
Session management: It manages client sessions.
•
Web services: It is a web service endpoint.
Multiple AOS's can be installed to spread the processing load over multiple servers. This improves
performance in larger implementations.
Clients
Microsoft Dynamics AX Rich Client is the primary client to access Microsoft Dynamics AX
functionality. Most forms displayed in the rich client are designed by using the MorphX
4
development environment. Role center pages are SharePoint pages that are displayed within a rich
client form. SQL reports are called from the rich client by using the report viewer control.
Enterprise Portal pages are displayed through a web browser. A subset of functionality and
reports are available on the portal.
Microsoft Office® can be used as a client to access the Microsoft Dynamics AX application and
data. Office add-ins are available out-of-the-box for Microsoft Excel and Microsoft Word.
Other Applications can be used as a client to the Microsoft Dynamics AX application. Examples
include mobile applications, specialized applications written in .net and legacy applications.
Applications can be integrated using methods such as web services or the .net business connector.
The .NET Business Connector is a client that has no user interface. It is designed for other
applications to access the Microsoft Dynamics AX business logic. End-users can use another
application as the user interface that interacts with the AOS through the .net Business Connector.
Developers can access the developer tools through the MorphX IDE in the Microsoft Dynamics
AX client or through Visual Studio Tools in Visual Studio.
Other Components
Internet Information Server (IIS)
IIS is a web server that delivers content such as web pages.
Enterprise Portal and SharePoint
IIS is required to host the Enterprise Portal framework within SharePoint. Role Centers require the
Enterprise Portal regardless of whether they are viewed through the web browser or the Microsoft
Dynamics AX Windows Client.
Help Server
Microsoft Dynamics AX Help files are hosted through IIS. When a user accesses Help from within
the rich client, the AOS generates a call to the Help server to display the Help pages.
Web Services
Web Services are hosted within IIS. The AOS is the web service endpoint that provides the data
that is served to other applications by IIS in a standardized format.
Development Environments
The Microsoft Dynamics AX application is built of elements that are stored in the model store in
the SQL Service database. For example, the following element types make up part of the
application:
•
•
Fields and Tables define data structure.
Forms and Menus define how a user interacts with the application.
•
Classes and Methods are code objects that define business logic.
The Application Object Tree (AOT) provides a visual representation of the elements that
comprise the application.
5
Object-oriented design and Inheritance are key concepts that form the basis of the application.
Model elements can be modified or added using a development environment. The development
environments that can be used with Microsoft Dynamics AX 2012 include:
•
•
Microsoft Visual Studio.
Microsoft Dynamics AX Integrated Development Environment (IDE). This is also
referred to as the MorphX IDE and is accessed through the developer workspace in the
Microsoft Dynamics AX client.
Application Object Tree
A full definition of all the element types in Application Object Tree (AOT) can be found in the
development training material and developer Help files. Some of the root element types include:
• Data Dictionary contains objects that define basic data structure.
o Tables contain a group of associated fields. For example the CustTable contains fields
relevant to customers. Fields on a table contain individual pieces of data. For example,
AccountNum contains the customer account number. Fields on a table inherit properties
from extended data types.
o Extended data types define a data type and extended properties. There are various basic
data types such as a string, integer, date, time and enum. For example, AccountNum is a
string extended with properties including a length of 20 characters, left justified and is
mandatory.
o Base Enums are enumerated text data types. These are predefined text values that are
referenced by an integer value in the database. These are presented to the user as a fixed list
of options. For example, Blocked is an enum that gives the user only two options (yes or
no) as to whether a customer account is on hold.
• Classes contain code that is used in the application.
•
Forms define the layout of all of the forms. Forms are used to view data in the Microsoft
Dynamics AX client.
•
Visual Studio Projects display any development projects created in Visual Studio.
•
Menus define forms and reports that appear in the menu in the Microsoft Dynamics AX
rich client.
6
FIGURE. AOT DISPLAYED IN THE DEVELOPER WORKSPACE
Labels
Labels are used to provide the language text that end-users see when using the application. All text
presented in the client displays the translation of a label code. The label codes usually are reused
wherever the exact same text is used with the same meaning. This makes it easier to manage
multiple languages and to adapt to company specific language.
MorphX IDE
The MorphX IDE is accessed through the Developer Workspace which provides access to the AOT
and other developer tools. It is used to make changes and add to the application. This is the most
commonly used development environment.
Common operations such as building or modifying tables, forms and menus can be performed by
using drag-and-drop techniques with little or no coding. X++ is the programming language that
is used in the MorphX IDE to write more advanced business logic.
X++ Tools
X++ is the object-oriented programming language that is used in the MorphX development
environment. X++ has C#-like syntax, and incorporates SQL data manipulation statements.
A full list of developer tools in the MorphX development environment can be found in the
developer help documentation. Some of the tools available include:
•
The X++ Code Editor is a text editor used to write X++ code. It supports color-coding and
allows to look up and select various objects such as method names and enumeration values
as you type.
•
The Debugger is an application used by developers to step through X++ code to help resolve
code errors.
•
The Reverse Engineering tool enables you to visualize data and classes in Microsoft
Dynamics AX by creating UML data models, UML object models, and ERX ER data models.
•
The Table browser displays data from all fields in a selected table. The table browser can
be used to run SQL statements.
Visual Studio
The Visual Studio development environment is integrated through Visual Studio Tools for
Microsoft Dynamics AX (Visual Studio Tools) and it supports managed code.
Close integration between MorphX and Visual Studio means developers can take advantage of the
benefits of each development tool and work in the environment that best suits their development
scenario.
Some development scenarios must take place in Visual Studio. This includes creating and
customizing SSRS reports, most Enterprise Portal web development and any managed code
development.
The Application Explorer is available within Visual Studio. This gives developers the ability to
browse AX metadata. The Application Explorer displays information that is similar to the AOT in
the MorphX IDE. Visual Studio projects are displayed in the AOT and are stored in the Microsoft
Dynamics AX model store in SQL server.
7
Development Projects
While developing in Microsoft Dynamics AX, you can group all your modifications in to a
development project. To create a new development project, click the project icon in the
development workspace, or press Ctrl-Shift-P. Private projects are visible to the user creating
them and shared project are visible to everyone.
To create a new shared project:
•
•
Right-click the Shared node and select New > Project.
Give the project a descriptive name and then double-click it to open it. Now any elements
from the AOT can be dragged in to this project.
This creates a reference to the element. Modifying elements in the project is the same as
modifying them directly in the AOT.
Model Driven Architecture
Microsoft Dynamics AX is designed with a unique layer and model structure that separates and
controls the updates and modifications made in the application. This structure provides a powerful
and flexible architecture for developing business logic.
The key benefit of the layer and model structure is that it lets developers change and extend the
functionality in Microsoft Dynamics AX while maintaining upgradability to new versions.
Layers
Application object layers hold all elements that are displayed in the AOT. There are eight
application object layers available. Each of these layers also has a patch layer making a total of
sixteen layers.
Layers are a hierarchy of levels in the application you can use to make modifications and additions
without interfering with the application elements in the next lower level. When you make an
element modification on one level, the modification overshadows the element on a lower level.
When the application is compiled, only the top-level version of an application element is used.
There are three layers available only to Microsoft to deliver the base application. (The xxP layer
indicates the patch layer for each application object layer).
Layer
Description
SYS, SYP
System layer: The standard application is developed in this lowest layer. This
includes the core application and the localization for most countries.
GLS, GLP
Globalization layer: Includes features developed for some countries that were
not yet moved into the SYS layer.
FPK, FPP
Feature Pack layer: Includes industry feature packs that are controlled by
Microsoft.
There are three layers available to partners and ISVs.
Layer
Description
SLN, SLP
Solution layer: Includes Microsoft endorsed industry solutions.
ISV, ISP
Independent Software Vendor layer: Includes generic or vertical solutions
developed by ISV's.
8
VAR, VAP
Value Added Reseller layer: Includes multi-customer solutions developed by
VAR's.
There are two layers available to both partners and customers who have a license to access the
AX source code.
Layer
Description
CUS, CUP
Customer layer: Includes customer specific functionality.
USR, USP
User layer: Includes installation specific functionality and customizations.
Models
A model is a logical grouping of elements within a layer. Models help in situations where multiple
ISV solutions or projects must operate together. This architecture allows many solutions to co-exist
within each layer.
An element can exist in exactly one model in a layer. The same element can exist in a customized
version in a model in a higher layer. New models are easy to create in the MorphX IDE and are
applied when modifying or adding objects in the AOT. Models can be exported, installed, or
uninstalled from the model store. Models are identified by a name and a publisher, and have a set
of properties that can be changed, including a version number.
Following is an example:
•
A company has two lines of business. They manufacture and sell medical products. They also
manufacture, sell and service specialized equipment to produce medical products.
•
Solution A is an advanced vertical solution for the production of food and drug products.
Among other things, this solution adds a new field to the item table to store the government
approval number. This is stored in the ISV layer and in the model MEDICAL.
•
Solution B is an advanced vertical solution for managing the ongoing service of equipment
which is sold to customers. Among other things, this solution adds a new field to the item
table for the default service period. This is stored in the ISV layer and in the model SERVICE.
•
You can use models to view the modifications to the item table made by all ISV solutions
and easily see where each change originated.
CHAPTER 2: DATA DICTIONARY
Introduction
This chapter introduces the tools and procedures used to create tables, data types, and relations
that are required in Microsoft Dynamics AX.
MorphX and the Application Object Tree
The Application Object Tree (AOT) is a tree view of all application elements in Microsoft
Dynamics AX. Each branch node contains a different application element type. Within the AOT, a
developer can create or modify Microsoft Dynamics AX application elements using drag-and-drop
functionality. The system has default settings for all application object properties.
9
Procedure: Opening the AOT
There are four different ways to open the AOT:
•
Navigate to Windows > New Development Workspace. A new development workspace
will open with the AOT visible.
FIGURE. OPENING THE DEVELOPMENT WORKSPACE
•
•
•
Press Ctrl-Shift-W.
Press CTRL + D.
Add the -development switch to the ax32.exe command when starting Microsoft Dynamics
AX.
FIGURE. DEVELOPMENT WORKSPACE AND AOT
Features of the AOT
AOT Toolbar
The toolbar located in the AOT contains five icons, and each icon also has a short-cut key.
The functions of these icons are as follows:
•
•
CTRL + O: Opens the application element directly from the AOT.
ALT + ENTER: Opens the properties sheet for the selected element.
CTRL + SHIFT + S: Saves any changes made to an element.
CTRL+SHIFT+I: Imports an .xpo file containing definitions of elements.
•
F7: Compiles the object to locate syntax errors.
•
•
10
NOTE: Microsoft Dynamics AX elements are exported as .xpo files. These are the only types of
files Microsoft Dynamics AX recognizes when trying to import into the AOT.
AOT Right-Click Menu
The right-click menu in the AOT differs slightly depending on the node. This section shows all the
functions of the right-click menu on the top level of the AOT, excluding the Data Dictionary.
Elements in the Data Dictionary
The following list shows all the element types in the Data Dictionary:
FIGURE. DATA DICTIONARY ELEMENT TYPES
•
Tables store data in the system. They contain fields of various data types, depending on the type of
data they hold. Data is entered, edited, and deleted through forms. Tables are discussed in more detail
later in the section.
•
Maps are used to link tables. By creating a map, fields can be accessed in different tables if the fields
are of similar types but have different names. For example, a class that implements functionality to
process data in the tables. If these tables use identical names for the columns, you can reuse data
processing classes.
•
Views are read only data representations that combine multiple table objects. Views present a selected
set of rows and columns by joining different tables through data sources and relations between them.
Frequently views represent a subset of fields from a single table to simplify reporting.
•
Extended Data Types are customized data types based on the primitive MorphX data types including
strings, integers, reals, dates, times, enums, or containers.
•
Base Enums are a list of literals that can be used throughout the development environment in
MorphX. Enums (enumerable type) are an extended data type that inherits from a base enum. The
elements in an enumerable type are created by using the AOT, where the name of the type and the
literals can be described in the definition.
•
Configuration keys disable features in the application for all users. Each key controls access to a
specific feature, and once it is disabled, the feature is automatically removed from the user view.
License codes control which elements can be enabled. If a license code is not purchased for a module,
then any element attached to that license code cannot be used.
•
•
Security keys are a legacy from previous versions of Microsoft Dynamics AX and will be removed
in the next version. Security is covered in detail later in this course.
•
Table collections do not contain any data. Virtual companies are built on table collections. They
contain tables shared by more than one company. A table can be a part of more than one table
collection.
•
Perspectives organize tables, folders, fields, and roles, in subsets according to application modules
in an intuitive way, matching the same concept as Microsoft SQL Server Reporting Services.
Perspectives are also discussed in more detail with the use of OLAP cubes.
11
Tables
The Microsoft Dynamics AX SQL database created during installation contains the complete table
repository. Tables are at the core of the Microsoft Dynamics
AX application and enable storage of a company's information and transactions.
Understanding Microsoft Dynamics AX Tables
Tables storing data about company transactions, inventory, general ledger, journals and more, form the base
of the Microsoft Dynamics AX application. These are referred to as base tables or application tables. Some
frequently used tables include:
AX Table
Name
Application Data Detail
CustTable
The table for basic customer information.
VendTable
The table for basic vendor information.
LedgerTable
The table for the general ledger that contains the
chart of accounts information.
InventTable
The table for the general inventory catalog.
PurchTable
The table for purchase order creation information.
Other tables in Microsoft Dynamics AX contain metadata. These tables contain descriptions of data.
Metadata is housed in system tables.
System tables are differentiated from application tables by the Sys prefix that starts the name of the table.
The following figure shows examples of system and application tables.
FIGURE. SYSTEM TABLES
Microsoft Dynamics AX Table Structure and Components
Tables in Microsoft Dynamics AX contain multiple elements that define the table. There are
seven categories that define tables:
•
•
•
Fields
Field Groups
Indexes
12
•
•
•
•
Full Text Indexes
Relations
Delete Actions
Methods
FIGURE. TABLE ELEMENTS
Fields
Access the Fields node using MorphX to create or modify the physical columns in the database
table. The fields defined within the Fields node are the columns belonging to the physical table.
Display all the fields for the LogisticsAddressZipCode table by opening the Fields node. The
following figure shows how MorphX is used to view all the columns within a Microsoft Dynamics
AX table.
FIGURE. FIELDS IN THE ZIP CODE
Field Groups
Field groups in Microsoft Dynamics AX are logical groupings of physical database fields. Microsoft
Dynamics AX uses Field Groups to cluster fields into logical groups so that these groups can be used on
forms and reports. An example of such a group is the group Measurement located on InventTable.
InventTable holds data relating to products, and the measurement fields are height, width, depth and density
of the products.
13
FIGURE. FIELD GROUPS
Indexes
The indexes in the Microsoft Dynamics AX table definition are the physical indexes that exist on
the tables in the database. Indexes accelerate a search on a table's data. More detailed information
on indexes is discussed later in this chapter.
Full-text Indexes
A full-text index contains location information about each significant word in a string field of a
table. Some queries can use this information to run more efficiently and to complete more quickly.
These are queries that search for words embedded in the middle of string fields.
A full-text index can be created by creating a new full-text index under the fulltext index node on
the table, and adding fields to this new full-text index.
Queries can use the full-text index by creating a query range of type Full-Text Index. If the value
in that range has multiple words, the space is treated like a boolean OR, so any records with at least
one of the words in the full text indexed fields will be returned.
X++ select statements cannot use a full-text index.
Relations
Microsoft Dynamics AX uses a relational database, which means that relationships can be created
between tables that contain related data. In Microsoft Dynamics AX, the relationship between
tables is called a relation.
Delete Actions
Microsoft Dynamics AX uses a category of methods called Delete Actions to govern how data is
handled when a deletion event occurs in a parent table. There are four types of delete actions:
•
None: The row in this table is deleted but nothing occurs in the specified table.
•
Cascade: The row in this table is deleted and all related data in the specified table is also
deleted. This ensures that no orphaned records remain after a deletion.
•
Restricted: The row in this table is only deleted if there is nothing that relates to it in the
specified table. This is used when a parent record should only be deleted when no child record
exists, and the child record is important to keep, for example, transaction records.
•
Cascade + Restricted: Behaves the same as Restricted.
NOTE: It is important to create delete actions and to create them correctly to ensure data integrity.
14
Methods
Microsoft Dynamics AX uses methods within the table node to perform functions specific to the
table. This can be data lookups to other tables based on data in that table, or manipulation of the
data during specific events.
Inheritance
A table can extend another table, by specifying the Extend property on the table. This means one
table inherits all of the fields, properties and methods of the table that it extends. New fields and
methods can be added to this extending table that will not be visible from the extended table.
Data Types: Primitive and Extended
Microsoft Dynamics AX uses data types to define how data is stored and restricted within the
database. There are primitive and extended data types (EDT).
Primitive Data Types
The basic set of primitive data types in Microsoft Dynamics AX map to underlying data types
that exist in the physical database. These primitive data types can be expanded to create Extended
Data Types, which are reusable data types having a specific definition.
The primitive data types used in Microsoft Dynamics AX are as follows:
Primitive
Description
String
A number of characters.
Integer
A number without a decimal point. 32 bits wide.
Real
A number with a decimal point.
Date
Contains day, month and year.
Time
Contains hours, minutes and seconds.
UTCDateTime
A combination of date and time types into one data type that also
holds time zone information.
Primitive
Description
Enum
A set of literals that are represented internally as integers.
Container
A composite data type that is a dynamic list of items containing
primitive data types and/or some composite data types.
GUID
Globally Unique Identifier. A 16-byte number generated that
uniquely identifies a network or interface.
Int64
A number without a decimal point. 64 bits wide.
Boolean
Only contains the values false and true.
Extended Data Types
EDTs extend primitive data types or other EDTs. The benefit of creating EDTs is the reuse of their
properties. For example, the label for one EDT can be inherited from the EDT that it extends.
15
A table field that is created based on an EDT will also inherit properties from that EDT.
Another benefit is more efficient maintenance. The properties of many fields can change at one
time by changing the properties on the EDT.
Most fields in Microsoft Dynamics AX tables are based on EDTs.
Indexes
Indexes in databases are used to locate records. They are stored separately in the database, and
contain a key that can be quickly located in the index, and a reference to the record. For example,
the CustIdx index of the customer table contains the account number of the customer. The account
number is unique and sequenced. This is then used to quickly lookup the customer record through
the reference.
There are two types of indexes: unique and non-unique. If a unique index is created based on a
column, Microsoft Dynamics AX ensures no duplicate key values occur in that column. Also,
updates on a column that contain a unique index, which violates the uniqueness of the column,
cause an error.
Non-unique indexes are created for performance reasons. They provide a quick way of retrieving
data, instead of performing a full-table search of all the records in a table. Do not create an index
if it is not needed because they use system space and must be updated every time system data is
created, edited, or deleted. This can slow down the updating process. However in most cases the
performance gain when selecting records far outweighs the performance loss when updating.
When an Index is created, it is recommended to give the Index a name reflecting the names of the
fields in the index, followed by the suffix Idx.
Creating Indexes
Creating an Index in Microsoft Dynamics AX always relates to the table where it is created. The
index can only be created on fields that exist in the table. These indexes can be unique or nonunique, and are based on a single column or multiple columns that exist within the table.
NOTE: A field of data type memo or container cannot be used in an index.
Primary Index
A primary key is one or more columns that uniquely identify one record in a table from all the other
records.
A primary index is a unique index for a table that defines the primary key for that table. To set an
index as a unique index, set the index property Allow Duplicates to No.
A typical example of the primary key is the CustTable where the customer's
AccountNum is used as a primary key. The AccountNum is used in the AccountIdx index, which
is a unique index. This index is then set as the primary index for the CustTable table in the
properties for the table.
To set the primary index on a table, open the property sheet for the table. The PrimaryIndex
property allows any unique index with a key that is mandatory and cannot be edited.
16
Surrogate Key
When a primary index is not specified, Microsoft Dynamics AX uses a Surrogate Key as the
primary index. This key is the RecId field and, if the table is saved per company, the DataAreaId.
The surrogate key is used on many relations between tables.
Relations
Relations between tables are used to associate rows in one table to rows in another table.
Relations are also used to:
•
•
•
•
Enforce business rules across tables
Create auto joins in forms (join one table to another table).
Look up values in other tables (using lookups and the View Details command).
•
Validate data by providing constraints.
Automatically propagate changes from one table to another by defining cascading relations.
•
Generating field help (hover over a field, and data from the related table is displayed).
Relationships can be created between tables using MorphX.
•
These relations are defined within the Microsoft Dynamics AX application and not at the
physical database level.
•
Relations govern the relationships between data in different tables such as foreign key
relationships.
•
Foreign key relationships between tables are always formed from the parent table.
Under the relations node you can create different types of relationships between the parent table
and other tables in Microsoft Dynamics AX.
•
Normal specifies related fields in another table. Multiple fields can be included in this
relation. For example, table LogisticsPostalAddress has a relation called State that defines the
relation to the LogisticsAddressState table. The values allowed in the state field are limited
depending on which country is entered.
•
Field fixed specifies related fields that restrict the records in the primary table. The fixed field
is normally an enum.
•
Related field fixed specifies related fields that restrict the records in the related table. The
related fixed field is normally an enum.
•
ForeignKey specifies a correspondence between a foreign key field in the present table to the
primary key field in another parent table. A ForeignKey can be a PrimaryKey or a Single Field
Altenate Key. When it is a Primary Key, the relation is on the primary key field, for example
customer account. When it is a Single Field Alternate Key, the relation is on the surrogate key,
which is usually the RecId.
Base Enumerations
Base enumerations, also called Base Enums, are pre-defined text values for a field that are referenced
through an integer value in the database.
17
FIGURE. GENDER BASE ENUM
The figure shows the Gender Base Enum, with the value of Male corresponding to the integer value of 1.
Views
A Microsoft Dynamics AX view is a virtual table that provides the data records and fields that are
specified by a query. The following sections describe views and how they retrieve data.
Like a table, a view uses fields and rows to represent data records. However, the data in a view is not
stored as a database object but is dynamically created when the view is accessed. A view uses a query to
retrieve data fields from one or more database tables.
In Microsoft Dynamics AX, use views where tables are used. For example, use a view in a form, a report,
and in X++ code. The following table shows the benefits of using a view instead of a table.
Benefit
Description
Focused Data
A view is used to retrieve and return only the data that is relevant for a
particular user or scenario.
Customized Data
A view enables the use of a complex query to create a
highlycustomized set of data. For example, a view often represents data
as a single table that is retrieved from multiple joined tables and uses
many conditions.
Performance
A view can improve performance by returning only relevant fields to
the user. In addition, a view definition is compiled which can provide
better performance than calling an equivalently complex query.
When a view is created, the view definition is generated and stored in the database. When that view is
accessed, the view dynamically retrieves the data that satisfies the view definition.
NOTE: Views are read-only. The data fields and tables that a view uses cannot be updated from that view.
Views are synchronized like tables. When a view is synchronized, the view definition is saved to the
database. Synchronization of an existing view causes the definition of that view to be dropped and recreated in the database.
18
Lab 1 - Create a New Model and Development Project
In this lab you will create a model and a development project to keep your modifications organized.
During the remainder of the course, any elements you modify or create should be added to this
project.
Scenario
Isaac, the Systems Developer, needs to make a number of modifications to the system. He wants
to be able to group all the elements he creates and modifies together in one place, and also make it
easy to move the modifications to test and production systems later.
Challenge Yourself!
Create a model called Dev1 and a development project called Dev1Training
Step by Step
1. Open a new development workspace (Devsee: Procedure: Opening the AOT, p 10).
2. Click Tools > Model Management > Create Model.
Then you can enter the model name, your company, which layer the model is in, the
version number, a full description, and a shorter description. The combination of name and
publisher make a unique model.
3. Enter Dev1 in the model name, your name in the publisher and Dynamics AX
Development 1 training labs in the description.
4. Click OK.
5. Click Close on the infolog dialog.
6. Press Ctrl-Shift-P to open the development projects window.
7. Right-click the Private node and select New > Project.
8. Rename the project to Dev1Training.
19
Lab 2 - Veterinary Surgery
The following step procedures and labs will demonstrate how to create a modification that can be used in a
veterinary surgery. The surgery procedure will need to keep track of each animal that arrives, the owners
of the animal, the species, the breed, and details of each visit including the date, reason and the cost.
To do this you will need to create the following new tables.
•
Species table: This will contain entries such as dog, cat, ferret and so on.
•
Breed table: This will contain the breed such as Labrador, Old English Sheepdog, Bengal, Siamese
and so on. This should be related to the Species Table.
•
Pet table: This information is related to the customer table and breed table.
•
Visit transactions: This will contain the details of each visit for each pet.
Lab 2.1 - Create a New EDT (Extended Data Types)
The Veterinary Surgery module also requires a new EDT for the Id of the Breed.
Challenge Yourself!
Create a new EDT that will be used for the breed Id. Set the label and help as appropriate. Ensure
the size of the field is consistent with the standard application.
Step by Step
1. Open a new development workspace (see: Procedure: Opening the AOT, p 10)
2. In the AOT, expand the Data Dictionary node.
3. Right-click the Extended Data Types node.
4. Select New > String. A new EDT called Type1 is created.
5. Right-click Type1 and select Properties.
6. Modify the property Name to VetBreedId.
7. Modify the property Extends to SysGroup.
8. Modify the property Label to Breed Id.
9. Close the property sheet and click Save in the AOT to save your changes.
10. On the Database Synchronization dialog, click Yes.
Setting the Extends property to SysGroup inherits properties from the SysGroup EDT. This sets
the size of the EDT to 10 characters, which is the standard size for an ID field such as this one.
The new EDT and property sheet should appear as follows:
20
FIGURE. CREATE VETSPECIESID EDT
Lab 2.2 - Create a New Table
Create a table that will store data for the breed.
Existing tables in Microsoft Dynamics AX can be modified or new tables can be created using the
MorphX tools in the AOT.
Challenge Yourself!
Create a new table that will store the breed of the pet. The table should have the fields BreedId
(type VetBreedID) and Name (type Name).
Step by Step
1. Open a new development workspace.
2. In the AOT, expand the Data Dictionary node.
3. Right-click on the Tables node and select New Table. A new Table called Table1 is
4.
5.
6.
7.
8.
9.
10.
11.
created.
Right-click Table1 and select Properties.
Modify the property Name to VetBreedTable.
Modify the property Label to Breed.
Close the property sheet.
Press Ctrl-D to open another AOT. Ensure window is not maximized by clicking the
restore down button to enable you to view both AOT windows.
Expand the Data Dictionary node.
Expand the Extended Data Types node.
Locate the VetBreedID EDT.
21
12. Drag the VetBreedID EDT to the Fields node of the VetBreedTable table. A new field
13.
14.
15.
16.
17.
18.
called VetBreedId is created.
Right-click the VetBreedId field and click Properties.
Note that the Extended Data type for this field is set to VetBreedId.
In the Name property, set the name of the field to BreedId.
Close the property sheet.
Locate the Name EDT in the second AOT.
Drag the Name EDT to the Fields node of the VetBreedTable table. A new field called
Name is created.
19. Save your changes to the table. When changes to a table are saved, Microsoft Dynamics AX
automatically synchronizes the changes made within its Data Dictionary with SQL: this
ensures that the definitions for the tables remain consistent at all times.
20. Use the previous step procedure to create a new table that will store the records for the
species. There are two fields on the table called SpeciesId (type VetSpeciesId), and Name
(type Name).
The new table and property sheet should appear as follows:
FIGURE. CREATE THE VETSPECIESTABLE TABLE
TIP: To view data in a table use the table browser, by pressing Ctrl-O. This opens the table in a
basic grid form. From here you can view, edit, create and delete data. This should be used only as
a developer tool, and should not be used to edit live data.
Lab 2.3 - Create a Primary Index (Indexes)
Challenge Yourself!
Set the index created in the last procedure as a primary index for the table. Create a primary index
for the Breed Table.
Step by Step
1. Locate the VetBreedTable table in the AOT.
2. Right-click the Indexes node in the table and select New Index. A new index Index1 is
created.
22
3. Rename the index to BreedIdx.
4. If you used the property sheet to rename the index, close the property sheet.
5. Drag the field BreedId to the index BreedIdx node.
6. In the properties sheet for the BreedIdx node, set the property AllowDuplicates to No,
7.
8.
9.
10.
AlternateKey to Yes.
Close the property sheet.
In the property sheet for the table, set the PrimaryIndex property on the table to BreedIdx.
Close the property sheet for the table.
Use the previous procedure to create a new index on the SpeciesId field on the
VetSpeciesTable.
FIGURE. CREATING AN INDEX
Lab 2.4 - Create a Relation (Relations)
Create another new table that will link customers to pets they own.
Procedure: Creating a Relation
Use this step procedure to create a relation between the breed and the species table. The breed is
related to the species table - a breed of Old English Sheepdog, is related to the record Dog in the
Species table. You should not be able to have a cat that has a breed of Old English Sheepdog.
1.
2.
3.
4.
5.
6.
In the AOT, locate the VetSpeciesId EDT.
Right-click the VetSpeciesId EDT and select Properties.
In the ReferenceTable property enter VetSpeciesTable.
Close the properties sheet.
Expand the VetSpeciesId node.
Right-click the Table References node and select New > Table. Reference. A new table
reference is created.
7. Right-click the VetSpeciesId Table Reference and select properties.
8. In the related field property, enter SpeciesId.
9. Close the property sheet and save your changes to the EDT.
10. If the database synchronization dialog appears, click Yes.
11. Drag the VetSpeciesID EDT to the field node on the VetBreedTable table.
12. When prompted to add the ForeignKey relation from the EDT, click Yes. This will
automatically create the relation between the VetBreedTable table and the VetSpeciesTable.
13. Rename the VetSpeciesId field to SpeciesId.
23
FIGURE. CREATING A RELATION
Challenge Yourself!
Create a new table that will store data about the pets belonging to each customer. The table will
need to have the following fields: Customer Account (Type CustAccount), PetName (Name),
Species (VetSpeciesId), Breed (VetBreedId). You should create two relations - one a foreign key
to the species table, and one a normal relation to the breed table so that it is limited based on the
species field entered.
Step by Step
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
Open a new development workspace.
In the AOT, expand the Data Dictionary node.
Right-click the Tables node and select New Table. A new Table called Table1 is created.
Right-click Table1 and select Properties.
Modify the property Name to VetCustPetTable.
Modify the property Label to Pets.
Close the property sheet.
Press Ctrl-D to open another AOT.
Expand the Data Dictionary node.
Expand the Extended Data Types node.
Locate the CustAccount EDT.
Drag the CustAccount EDT to the Fields node of the VetCustPetTable table.
Locate the VetSpeciesId EDT.
Drag the VetSpeciesId EDT to the Fields node of the VetCustPetTable table. A new
field called VetSpeciesId is created.
Click Yes to create the foreign key
Right-click the VetSpeciesId field and click Properties.
In the Name property, set the name of the field to SpeciesId.
Close the property sheet.
Locate the VetBreedID EDT.
Drag the VetBreedID EDT to the Fields node of the VetCustPetTable table. A new
field called VetBreedId is created.
Right-click the VetBreedId field and click Properties.
In the Name property, set the name of the field to BreedId.
Close the property sheet.
Locate the Name EDT in the second AOT.
24
25.
26.
27.
28.
29.
30.
31.
32.
Drag the Name EDT to the Fields node of the VetBreedTable table. A new field called
Name is created.
Right-click the Relations node on the VetCustPetTable node and select New Relation.
In the properties sheet for the new relation, set the Name property to VetBreedTable and
the Table property to VetBreedTable.
Right-click the VetBreedTable relation, select New > Normal.
In the property sheet for the new normal relation, set the Field to BreedId and the
RelatedField to BreedID.
Right-click the VetBreedTable relation, select New > Normal.
In the property sheet for the new normal relation, set the Field to SpeciesId and the
RelatedField to SpeciesId.
Save your changes.
Relations can also be added manually by right-clicking the relations node on the table. However when you
create the reference on the EDT and set it as a primary key, once the EDT is added to a table, the system
will prompt to add the reference automatically.
Lab 2.5 - Add an Enum (Base Enumerations)
The pet table needs to store whether the animal is male or female.
Challenge Yourself!
Add the Gender Enum to the VetCustPetTable table.
Step by Step
1. Locate the Gender enum in the Base Enums node in the AOT.
2. Drag the Gender enum to the Fields node in the VetCustPetTable table.
3. Save your changes to the table.
Содержание
Introduction .............................................................................................................................................................. 1
Features of Microsoft Dynamics AX ........................................................................................................................ 1
Client Workspace.................................................................................................................................................. 1
Architecture .............................................................................................................................................................. 2
Three-Tier Architecture ........................................................................................................................................ 2
Extended Architecture .......................................................................................................................................... 3
SQL Server Databases .......................................................................................................................................... 4
Microsoft Dynamics AX Database ................................................................................................................... 4
Business Intelligence (BI) Databases ............................................................................................................... 4
Application Object Server .................................................................................................................................... 4
Clients ................................................................................................................................................................... 4
Other Components ................................................................................................................................................ 5
Enterprise Portal and SharePoint ...................................................................................................................... 5
Help Server ....................................................................................................................................................... 5
25
Web Services .................................................................................................................................................... 5
Development Environments ..................................................................................................................................... 5
Application Object Tree ....................................................................................................................................... 6
Labels.................................................................................................................................................................... 7
MorphX IDE ......................................................................................................................................................... 7
X++ Tools ............................................................................................................................................................. 7
Visual Studio ........................................................................................................................................................ 7
Development Projects ........................................................................................................................................... 8
Model Driven Architecture ....................................................................................................................................... 8
Layers ................................................................................................................................................................... 8
Models .................................................................................................................................................................. 9
Introduction .............................................................................................................................................................. 9
MorphX and the Application Object Tree ................................................................................................................ 9
Procedure: Opening the AOT ............................................................................................................................. 10
Features of the AOT ........................................................................................................................................... 10
Elements in the Data Dictionary ......................................................................................................................... 11
Tables...................................................................................................................................................................... 12
Understanding Microsoft Dynamics AX Tables ................................................................................................ 12
Fields .................................................................................................................................................................. 13
Field Groups ....................................................................................................................................................... 13
Indexes ................................................................................................................................................................ 14
Full-text Indexes ................................................................................................................................................. 14
Relations ............................................................................................................................................................. 14
Delete Actions .................................................................................................................................................... 14
Methods .............................................................................................................................................................. 15
Inheritance .......................................................................................................................................................... 15
Data Types: Primitive and Extended ...................................................................................................................... 15
Primitive Data Types .......................................................................................................................................... 15
Extended Data Types .......................................................................................................................................... 15
Indexes .................................................................................................................................................................... 16
Creating Indexes ................................................................................................................................................. 16
Primary Index ..................................................................................................................................................... 16
Surrogate Key ..................................................................................................................................................... 17
Relations ................................................................................................................................................................. 17
Base Enumerations ................................................................................................................................................. 17
Views ...................................................................................................................................................................... 18
Lab 1 - Create a New Model and Development Project ......................................................................................... 19
Lab 2 - Veterinary Surgery ..................................................................................................................................... 20
Lab 2.1 - Create a New EDT .................................................................................................................................. 20
Lab 2.2 - Create a New Table ................................................................................................................................. 21
Lab 2.3 - Create a Primary Index ............................................................................................................................ 22
Lab 2.4 - Create a Relation ..................................................................................................................................... 23
26
Lab 2.5 - Add an Enum........................................................................................................................................... 25
27