Reference Companion Guide 80730
Reference Companion Guide 80730
The Reference Companion Guide should be used in conjunction with an E-Learning or trainer led instruction
course.
____________________________________________________________________________________________________________________
NOTE:
Module practices and demonstrations in this course are performed on prerelease version of Microsoft Dynamics
AX (Version AX7 CTP7).
All practices should be performed in the same sequence as the course, as they are interdependent.
____________________________________________________________________________________________________________________
CONTENTS
Module 0: Fleet Management Case Study........................................................................................................................................... 7
Module 1: Introduction to Visual Studio.............................................................................................................................................. 7
Lesson 1: Module Overview..................................................................................................................................................7
Lesson 2: Fleet Management Scenario..................................................................................................................................7
Lesson 3: Setup and Configuration........................................................................................................................................7
Lesson 4: Terminology and Concepts....................................................................................................................................8
Lesson 5: Naming Convention...............................................................................................................................................8
Lesson 6: Navigation.............................................................................................................................................................8
Lesson 7: Projects, Models, and Packages...........................................................................................................................10
Lesson 8: Using Elements....................................................................................................................................................12
Lesson 9: Performing Builds................................................................................................................................................13
Module Review............................................................................................................................................................................................ 14
MODULE 1 KEY TAKE AWAY..................................................................................................................................................................... 14
MODULE P RACTICE....................................................................................................................................................................................... 15
Practice 1.1: Configure Visual Studio................................................................................................................................................... 15
Practice 1.2: Create a Project.................................................................................................................................................................. 16
Practice 1.3: Create an Element............................................................................................................................................................. 17
Practice 1.4: Build and Compile............................................................................................................................................................. 18
Module 2: Architecture............................................................................................................................................................................. 20
Lesson 1: Application Stack.................................................................................................................................................20
Lesson 2: Server Architecture..............................................................................................................................................20
Lesson 3: Cloud Architecture...............................................................................................................................................21
Module Review............................................................................................................................................................................................ 21
MODULE 2 KEY TAKE AWAY ..................................................................................................................................................................... 21
Module 3: Labels and Resources........................................................................................................................................................... 24
Lesson 1: Labels................................................................................................................................................................... 24
Lesson 2: Fleet Management Scenario................................................................................................................................24
Lesson 3: Create and Use Labels.........................................................................................................................................24
Lesson 4: Search Labels.......................................................................................................................................................25
Lesson 5: Best Practices for Labels......................................................................................................................................25
Lesson 6: Resources............................................................................................................................................................25
Lesson 7: Create and Use Resources...................................................................................................................................25
Module Review............................................................................................................................................................................................ 26
MODULE 3 KEY TAKE AWAY ..................................................................................................................................................................... 26
MODULE P RACTICE....................................................................................................................................................................................... 27
Practice 3: Create Labels........................................................................................................................................................................... 27
MODULE 3: Y OUR NOTES.......................................................................................................................................................................... 29
Module 4: Base Enumerations................................................................................................................................................................ 30
Lesson 1: Fleet Management Scenario................................................................................................................................30
Lesson 2: Create a Base Enumeration.................................................................................................................................30
Lesson 3: Best Practices......................................................................................................................................................31
Module Overview........................................................................................................................................................................................ 32
MODULE 4 KEY TAKE AWAY ..................................................................................................................................................................... 32
MODULE P RACTICE....................................................................................................................................................................................... 33
Practice 4: Create Base Enumerations................................................................................................................................................. 33
MODULE 4: Y OUR NOTES.......................................................................................................................................................................... 36
Module 5: Extended Data Types.......................................................................................................................................................... 37
Lesson 1: Fleet Management Scenario................................................................................................................................37
Lesson 2: Primitive Data Types............................................................................................................................................37
Lesson 3: Create an EDT......................................................................................................................................................37
Lesson 4: Best Practices......................................................................................................................................................39
Module Review............................................................................................................................................................................................ 39
MODULE 5 KEY TAKE AWAY ..................................................................................................................................................................... 39
MODULE P RACTICE....................................................................................................................................................................................... 40
Practice 5: Create Extended Data Types (EDTs)............................................................................................................................... 40
Module 6: Tables........................................................................................................................................................................................ 45
Lesson 1: Fleet Management Scenario................................................................................................................................45
Lesson 2: Create a Table......................................................................................................................................................45
Lesson 3: Adding Data Types...............................................................................................................................................46
Lesson 4: Key Properties.....................................................................................................................................................47
Lesson 5: Table Inheritance.................................................................................................................................................48
Lesson 6: Temporary Tables................................................................................................................................................49
Lesson 7: Queries................................................................................................................................................................ 49
Lesson 8: Best Practices......................................................................................................................................................50
Module Review............................................................................................................................................................................................ 52
MODULE 6 KEY TAKE AWAY ..................................................................................................................................................................... 52
MODULE P RACTICE....................................................................................................................................................................................... 54
Practice 6.1: Create Tables....................................................................................................................................................................... 54
Practice 6.2: Create Queries.................................................................................................................................................................... 56
Module 7: Table Indexes.......................................................................................................................................................................... 59
Lesson 1: Fleet Management Scenario................................................................................................................................59
Lesson 2: Index Types..........................................................................................................................................................59
Lesson 3: Create an Index....................................................................................................................................................59
Lesson 4: Best Practices......................................................................................................................................................60
Module Review............................................................................................................................................................................................ 60
MODULE 7 KEY TAKE AWAY ..................................................................................................................................................................... 61
MODULE P RACTICE....................................................................................................................................................................................... 61
Practice 7: Create an Index...................................................................................................................................................................... 61
Module 8: Table Relations....................................................................................................................................................................... 64
Lesson 1: Fleet Management Scenario................................................................................................................................64
Lesson 2: Relations..............................................................................................................................................................64
Lesson 3: Creating a Relation..............................................................................................................................................65
Lesson 4: Best Practices......................................................................................................................................................65
Module Review............................................................................................................................................................................................ 66
MODULE 8 KEY TAKE AWAY ..................................................................................................................................................................... 66
MODULE P RACTICE....................................................................................................................................................................................... 66
Practice 8: Create a Table Relationship............................................................................................................................................... 66
Module 9: Form Patterns.......................................................................................................................................................................... 69
Lesson 1: Form Patterns and Sub-patterns - Part 1.............................................................................................................69
Lesson 2: Form Patterns and Sub-patterns - Part 2.............................................................................................................70
Lesson 3: Form Patterns and Sub-patterns - Part 3.............................................................................................................72
Lesson 4: Layout Properties................................................................................................................................................73
Lesson 5: Check Form Pattern.............................................................................................................................................74
Module Review............................................................................................................................................................................................ 75
MODULE 9 KEY TAKE AWAY ..................................................................................................................................................................... 75
Module 10: Form Creation...................................................................................................................................................................... 78
Lesson 1: Fleet Management Scenario................................................................................................................................78
Lesson 2: Create a Form......................................................................................................................................................78
Lesson 3: Form Controls......................................................................................................................................................78
Lesson 4: Adding Elements..................................................................................................................................................80
Lesson 5: Best Practices......................................................................................................................................................83
Module Review............................................................................................................................................................................................ 83
MODULE 10 KEY TAKE AWAY .................................................................................................................................................................. 83
MODULE P RACTICE....................................................................................................................................................................................... 84
Practice 10.1: Create Forms..................................................................................................................................................................... 84
Practice 10.2: Adding Elements............................................................................................................................................................. 85
Module 11: Menus...................................................................................................................................................................................... 89
Lesson 1: Fleet Management Scenario................................................................................................................................89
Lesson 2: Creating Menu Items...........................................................................................................................................89
Lesson 3: Creating Menus...................................................................................................................................................90
Module Review............................................................................................................................................................................................ 92
MODULE 11 KEY TAKE AWAY .................................................................................................................................................................. 92
MODULE P RACTICE....................................................................................................................................................................................... 93
Practice 11.1: Create Menu Items......................................................................................................................................................... 93
Practice 11.2: Create a Menu.................................................................................................................................................................. 94
Module 12: X++ Overview...................................................................................................................................................................... 98
Lesson 1: Fleet Management Scenario................................................................................................................................98
Lesson 2: Code Editor..........................................................................................................................................................98
Lesson 3: Create a Runnable Class......................................................................................................................................98
Lesson 4: Intellisense..........................................................................................................................................................99
Lesson 5: Data Types...........................................................................................................................................................99
Lesson 6: Variable Declaration..........................................................................................................................................100
Lesson 7: Key Operators....................................................................................................................................................101
Lesson 8: Basic Syntax - Part 1...........................................................................................................................................102
Lesson 9: Basic Syntax - Part 2...........................................................................................................................................104
Lesson 10: Comparison Tools............................................................................................................................................105
Lesson 11: Debugger.........................................................................................................................................................105
Lesson 12: Best Practices..................................................................................................................................................106
Module Review.......................................................................................................................................................................................... 107
MODULE 12 KEY TAKE AWAY ............................................................................................................................................................... 107
MODULE P RACTICE.................................................................................................................................................................................... 112
Practice 12: Create a Runnable Class................................................................................................................................................ 112
Module 13: Classes.................................................................................................................................................................................. 114
Lesson 1: Fleet Management Scenario..............................................................................................................................114
Lesson 2: Class Structure...................................................................................................................................................114
Lesson 3: Create a Base Class............................................................................................................................................114
Lesson 4: Methods............................................................................................................................................................114
Lesson 5: Class Inheritance................................................................................................................................................116
Lesson 6: Best Practices....................................................................................................................................................117
Module Review.......................................................................................................................................................................................... 118
MODULE 13 KEY TAKE AWAY ............................................................................................................................................................... 118
Module 14: Database Manipulation.................................................................................................................................................. 121
Lesson 1: Fleet Management Scenario..............................................................................................................................121
Lesson 2: Data Retrieval....................................................................................................................................................121
Lesson 3: Reading Records................................................................................................................................................122
Lesson 4: Transaction Integrity Checking..........................................................................................................................123
Lesson 5: Data Insert.........................................................................................................................................................124
Lesson 6: Data Updates.....................................................................................................................................................126
Lesson 7: Data Deletion.....................................................................................................................................................127
Module Review.......................................................................................................................................................................................... 127
MODULE 14 KEY TAKE AWAY ............................................................................................................................................................... 128
Module 15: Exception Handling.......................................................................................................................................................... 130
Lesson 1: Fleet Management Scenario..............................................................................................................................130
Lesson 2: Exception Types.................................................................................................................................................130
Lesson 3: Key Commands..................................................................................................................................................130
Lesson 4: Code Statements...............................................................................................................................................131
Module Review.......................................................................................................................................................................................... 133
MODULE 15 KEY TAKE AWAY ............................................................................................................................................................... 133
Module 16: Security Basics................................................................................................................................................................... 136
Lesson 1: Security Architecture Overview.........................................................................................................................136
Lesson 2: Create a Role.....................................................................................................................................................138
Lesson 3: Create a Duty.....................................................................................................................................................139
Lesson 4: Security Properties on Key Elements.................................................................................................................139
Module Review.......................................................................................................................................................................................... 140
MODULE 16 KEY TAKE AWAY ............................................................................................................................................................... 140
Module 17: Introduction to Advanced Topics............................................................................................................................... 144
Lesson 1: Business Intelligence.........................................................................................................................................144
Lesson 2: Reporting Services.............................................................................................................................................145
Lesson 3: Services and Integration....................................................................................................................................145
Lesson 4: Data Entities......................................................................................................................................................146
Module Review.......................................................................................................................................................................................... 147
Module 0: Fleet Management Case Study
Throughout this course, we're going to progressively build upon the Fleet Management scenario. As we
proceed through the different lessons we will develop the case study further and further with
business requirements, demonstrations, and examples for each module.
The Fleet Management case study is a scenario designed to give you exposure to the main components and
elements of the development environment and Visual Studio. For our scenario, we have a company called
Contoso Entertainment Systems USA. They're going to extend their operations to manage their internal fleet of
vehicles.
In order to meet the business requirements, developers at Contoso will modify the application to meet those
needs. At a high level, the system will be used to track all fleet vehicle information
and service and maintenance of those vehicles.
So, in the screenshot, we have two tables and one is going to be a general vehicle table that contains
information like make, model and VIN number. Another table will have maintenance information, such as the
type of maintenance, date of service, parts used and so on.
Module Review
In this module, we learned how to set up and navigate the development environment in Visual Studio for
Dynamics AX. We defined some important terminology and concepts and we learned a bit about naming
conventions. Then we looked at how to create packages, models and projects, as well as creating elements and
adding them to our projects. Finally, we covered the different options and methods for building our elements
for use within the application.
System Requirements
Minimums:
o 16GB RAM
o 2 CPU cores
Elements
Models
Group of elements
Projects
Packages
Naming Conventions
Camel case
Maintain consistency
Example: DBVehicle
Navigation
Model View
Solution Explorer
Properties window
Code editor
Dynamics AX Menu
Project properties
Using Elements
Element designer
Performing Builds
Building operations
Metadata and X++ code validation
Database synchronization
MODULE PRACTICE
Practice 1.1: Configure Visual Studio
Scenario
For the introduction to Visual Studio for the fleet management scenario we will need to complete the following
four tasks in the next four practices.
Configure the VS environment for AX development.
Create a new model, package, and a project.
Create an element within the project.
Build the project.
Simon, the Systems Developer for Contoso, is tasked with creating a new model for the Fleet Management
System in Visual Studio. He is to ensure that it is ready for element creation and that the project builds.
Simon, the Systems Developer for Contoso, is tasked with creating a new model for the Fleet Management System in
Visual Studio. He is to ensure that it is ready for element creation and that the project builds. This practice is in
continuation of the previous practice
Detailed Steps
1. Right Click on the Visual Studio icon on the desktop and select Run as Administrator.
2. On the Visual Studio menu, click Dynamics ‘AX 7’
3. Click Model Management > Create Model
a. Model name: DevelopmentBasicsFMS
b. Model publisher: AX Developer
c. Layer usr
d. Version 1.0.0.0
e. Model description: Example Fleet Management System for Development Basics to illustrate and
practice development tasks.
f. Model display name: DevelopmentBasicsFMS
4. Click Next
5. Select Create new Package
6. Click Next
7. Select the following referenced models
a. Application Platform
b. Application Foundation
c. Application Suite Electronic Reporting Integration, Application Suite
d. Application Platform Form Adaptor
e. Application Suite Form Adaptor
f. Application Workspaces
g. Application WorkspacesFormAdaptor
8. Click Next
9. On Summary, ensure check boxes are checked for:
a. Create new project
b. Make this my default model for new projects.
10. Click Finish
11. Select Dynamics AX7 Project
12. Enter DevelopmentBasicsFMSProject in the Name field.
13. Click OK
Simon, the Systems Developer for Contoso, is tasked with creating a new model for the Fleet Management System in
Visual Studio. He is to ensure that it is ready for element creation and that the project builds. This practice is in
continuation of the previous practice
Simon, the Systems Developer for Contoso, is tasked with creating a new model for the Fleet Management System in
Visual Studio. He is to ensure that it is ready for element creation and that the project builds. This practice is in
continuation of the previous practice
Module Review
In this module, we described the components included in the application stack. We reviewed the server
architecture. And we explained the cloud architecture that is used in Dynamics AX.
Application Stack
Application Platform
Core of application
SSRS reporting
Application Foundation
Organization model
Number sequence
Global address book
Source documents
Application Suite
Server Architecture
Architecture
Database
Metadata
Security
Caches
Workflow
Batch
Forms engine
Organized by model
Cloud Architecture
Lifecycle services
Capabilities:
o Software development
o Customer provisioning
o Reporting capabilities
Shared services
One Microsoft
o Single login
o Subscription management
Office 365
Power BI
Online services
Dynamics AX
Different topologies
o Demo
o Development/test
Demo
Development/test
Microsoft Azure
o Azure storage
o Networking
o Monitoring
o SQL Azure
o Etc.
MODULE 2: YOUR NOTES
Module 3: Labels and Resources
Welcome to Module 3. In this module, we'll learn about labels and resources. The objectives for this module
are to learn about labels and why we use them in AX. We will review the purpose of the labels for our fleet
management scenario. And then we will create and use both label files and labels. We will explore the search
capability of the label editor, and we will review the best practices for using labels. And finally, we will learn
about resources. And we'll create some and use them in our fleet management scenario.
Lesson 1: Labels
In the first lesson, let's discuss using labels. Label files are small data structures that keep all related and new
labels in a central storage file. For example, you can have a label file for your instance of AX, for your specific
company, or simply for a model. Labels themselves are a reference from the element or artifact in the system
that point back to the label file. This way, labels can have multiple versions depending on language settings.
They could return the correct value depending on the specified language in the system. This is also a more
efficient tool than hard coding values. For example, say a company now uses the term team member instead
of employee. When we update the label, the change is propagated to everywhere in the system where
employee is currently used. You should use labels to specify the user interface text for forms and reports.
Labels are created in the label editor and then used in text-based properties in the AOT or in X++ code.
Lesson 6: Resources
In this lesson, we will discuss how resources are created and used. Resources are the way to manage the
pictures, icons, and other visual representations that will be used within the user interface. This can be
accessed through the resource library, adding additional resources or using resources that are at a URL
location. The URL location would be used in the case of an IIS server instance with an established product
photo library.
Module Review
In this module, we learned about labels in AX and how and when to use them. We reviewed the use of labels
for our fleet management scenario and then we created and used both label files and labels. Then we explored
a search capability of the label editor. Next, we reviewed best practices for using labels. And finally, we
learned about resources, and then we created and used some resources in our application.
Labels
Small data structures that keep all related and new labels in a central storage file
Label creation
Searching
Resources
Pictures
Icons
Visual representations
Create and Use Resources
Solution Explorer
For the Fleet management System, there will need to be two items created. First, there will need to be a label
file to hold the labels that are included for the Fleet Management model. Second, for all of the artifacts and
elements you create, they will each need their own label.
Simon, our AX developer, will need to create a label file within our DevelopmentBasicsFMSProject so that all of
our label files will be contained with our model. Next, he will create the appropriate labels for our model.
Module Overview
Thank you for joining me in the base enumerations module. In this module, we introduced the data types
node and the Application Explorer and discussed how and when you should create new base enumerations.
We also reviewed a few examples of base enumerations that are used with AX and I showed you how to create
new base enums. Finally, we reviewed the best practices and considerations for using base enumerations with
your projects.
List of literals
Saves space
Best Practices
Consider:
Length
If it should be mandatory
If it is a special type
MODULE PRACTICE
Practice 4: Create Base Enumerations
Scenario
For our fleet management scenario, we will need to build three enumerations. These will aid in tracking the vehicle type,
service type, and the fuel type.
Simon, our AX developer, will need to create three base enumerations needed for our model.
-dbfmServiceType
None
Registration
OilChange
Maintenance
Repair
-dbfmVehicleType
Car
Truck
Van
SUV
-dbfmFuelType
Gas
Diesel
Propane
Natural Gas
Electric
Module Review
Thanks for joining me in the extended data types module. We took a look at each of the primitive types that
are used in AX and looked at several examples of creating new extended data types and setting properties
specific to those types. Then we discussed the best practices for using extended data types in your solutions.
Types
Anytype
Booleans
Enums
GUIDs
Integers
Real
o AKA decimals
String
o Number of characters
TimeOfDay
UTCDateTime
Create EDTs
Benefits of EDTs
Reduce work
Best Practices
MODULE PRACTICE
Practice 5: Create Extended Data Types (EDTs)
Scenario
The business users at Contoso have identified a variety of information that needs to be tracked in the new
system as a part of the fleet management system.
Simon, the Systems Developer at Contoso, has reviewed the list and categorized each piece of information into
the type of data that will be stored, and now needs to create or find existing EDTs to use for the Fleet
Management solution.
Isaac creates a new page, defines the variables and the layout of the page, and then adds an action that
calculates a relational expression.
Lesson 7: Queries
In this lesson, we'll talk about the creation, use, and benefits of queries. A query element can be designed as a
modular business object. Queries can contain one or more tables as a data source. These tables may be
nested within each other if they are related like in the screen shot. We have a FMT customer table and an FMT
customer group table nested and related to that table below it. Queries are flexible because they're easily
changed and can be modified at runtime. For example, a report that uses a query as a data source can have
parameters set dynamically at runtime before the report is executed. You can also change other options like
ordering by certain fields at runtime as well. A query object can then be reused as a data source to provide
data for other forms and reports in the system. So now let's go ahead and add a query element to our project.
Now, we discussed a bit about queries and how they are very flexible and very reusable. They're a good data
source that we can reuse for forms and reports. And they also allow us to specify details at runtime before we
execute them. So if we right click our project again, we can choose add and we'll add new item. And queries
live here in the data model element type group just above table. So we'll select it and we'll type a name for our
query. We'll call it dbVehicle query. I want this query to be based off my vehicle table. I'll add it. We have our
new folder here with the query element itself and it's opened here in the element designer. So let's go ahead
first of all and give it a title. So we'll set this property. We'll just call it vehicles. OK. Now, the data source's
node specifies which table or tables we're going to have as a data source for this query. I could go to my
project and open up my tables folder and simply drag a table to the data source's node. So now, I have my
dbVehicle table as my data source. If I expand the data source itself, we can see there's fields which specify
what fields we want to include from that table in this query. By default, none are added. We can right click and
choose new and we can choose a field and then this will allow us to specify which table in the query that we
want the table to come from and then which field that we're going to add. So I can see here in my drop down
that I'm going to have different options for choosing the tables and fields. So here's all the fields I can add. I
can add them one by one to choose only a subset of field that I want in this query. Maybe I have a specific
purpose for this query that's only going to use a couple fields, so we can go ahead and manually add fields to
the query simply by right clicking and choosing new field. We also have the option to have some of these
aggregate features in a query if we want to sum up a field from our table. We can also have that feature. So
I'm going to delete this manual field real quick. And there's another option we can use for queries which is
called the dynamic fields. So if I choose my dbVehicle data source table, and I go to the properties, there's an
option here called dynamic fields. And by default, it's unselected. We need to set this to yes or no. If I set it to
yes, it dynamically adds all of the fields, including system fields, from my dbVehicle table into the data source
for my query. The benefit of this is if, in the future, I decide to add more fields to my vehicle table, they will
dynamically update here in my query that has that table as a data source. So it's important to note if that
feature would suit you. OK. So we can go ahead and close up these tabs here and we'll save our query. OK.
So now I'm going to add one more query to this project. So I'll right click my project again and repeat the
steps by going to add, new item, choosing query from the data model artifact group, and give it a name. We'll
call this one dbVehicleMaintenance. And it goes ahead and adds a new query here to my simple queries folder
and it opens in the element designer by default. So what I want to do with this query is, first of all, add a data
source. Now, on my last vehicle query, I added the vehicle table as the single and only data source. For this
one, I want to add both the dbVehicle and the dbMaintenance table. To do that, I'll first click my dbVehicle
table and drag it to the data source's node. When I expand this data source, I have some different options
here, and we can see another data sources node exists. This gives me the option to create a nested data
source and that's what I want to do for my dbMaintenance table. I want it to be a nested data source within
my dbVehicle table. So I'll drag that out to this data source's node. And we can see if I continue to expand this
nested data source, there are options to continually add more and more data sources within data sources. So
when I create this nested data source within my dbVehicle main data source, I need to specify a relationship
between them so that these data sources know how they are related and they can communicate that way. So
I'll right click my relations node in my nested data source, and choose new relation. I'll go to the properties
pane over here and set a few properties to set up the relation. Firstly, I'll go to the field property and use the
drop down to specify which field in my dbMaintenance nested data source I want to use in the relation. And
that's going to be the vehicle ID field. For joined data source, if I click the drop down, we'll notice we only have
the dbVehicle table as an option because that is the only other data source in this query and it's the parent
data source for this nested data source. So I'll choose that, and then in the related field property, I'll choose
which field from this joined data source parent that I want to use in the relation. In other words, which field in
the dbVehicle table I'm going to relate to the vehicle ID field and the maintenance table. And that field is the
same, the same name in both places, dbVehicleID. So once I finish choosing those properties, we can see it
populates here this relation, the details. DbVehicletable.dbvehicleID field equals the dbMaintenance table and
the dbVehicleID field. So that's exactly what I wanted. The last thing I'll do is just give this joined relation a
name, and I'll just call it the vehicle ID relation. And I can go ahead and save this query. Some last things to
note about queries are these different options here. We already discussed adding fields to a data source and
other data sources within a data source. We also have the option within these data sources to add a range
which is created on a field or fields and specifies a searchable range or parameter for the query. And then we
also have the group by having an order by. For group by and order by, we can specify which field we want the
data to be ordered by in the query or which field we want the data to be grouped by in the query.
About tables
Table components
Fields
Field groups
Indexes
Relations
Delete Actions
Not used
Methods
Pieces of code added to a table executed when certain events occur
State machine
Mapping
Includes:
Fields
Base enums
Key Properties
Table type
Label
PrimaryIndex
ClusterIndex
ConfigurationKey
Support Inheritence
Extends
Table Inheritance
Temporary Tables
TempDB
InMemory
Queries
Highly flexible
Best Practices
Table
Naming
Labels
Form reference
Title fields
Table group
Table types
Table fields
Field groups
Query
Create queries in the Application Explorer instead of X++ code when possible
Always use queries as the data source for Forms and Reports
MODULE PRACTICE
Practice 6.1: Create Tables
Scenario
Two tables have been identified for the new fleet management module for Contoso including a table to store
basic vehicle information and a second table to store vehicle maintenance information.
The table for the vehicles will need to track the following information: fuel level, fuel type, gross vehicle weight,
inspection date, make, mileage, model, notes, number of doors, seating capacity, third row seating, a unique
vehicle ID, vehicle type, VIN and year.
The table for maintenance will need to track the following information: service type, engine description, service
start and end dates, and the vehicle ID.
For the Fleet Management Scenario Simon, the developer for Contoso, needs to create tables to store
information about the various types of vehicles in the fleet.
In addition, each of the tables will need a query to return the data for forms and reports.
Module Review
Thanks for joining me in the table indexes module. In this module, we introduced the various types of indexes
that can be added to tables and the purpose for each type of index. Then we created new indexes and
reviewed the best practices for using indexes in AX.
MODULE 7 KEY TAKE AWAY
o Table Indexes
Index Types
Primary Index
Clustered Index
Non-Clustered Index
Provides way to quickly reference data found in clustered index or heap using
specified set of columns
Create an Index
About indexes
Indexes are associated with tables and make it easier to find specific data
Best Practices
Add an index if the speed gained by adding it is greater than the cost of updating
it
Limit the number of columns in an index
MODULE PRACTICE
Practice 7: Create an Index
Scenario
For the fleet management scenario, we will need to add and index. For our example, we will have created the
table new. It is assumed that there is no data in the table before we begin. First we plan our index. Next we
add the required index to the table. Third we set the required parameters. Finally, we build our solution.
Simon, the Systems Developer at Contoso, has evaluated the amount and type of data that will be stored in the
vehicles tables and determined that an index should be added for vehicle ID for a more efficient link from
Vehicles to Vehicle Maintenance
Lesson 2: Relations
In this lesson, we will describe how relations function in tables as well as the different types of table relations
and their uses. A relationship is created between tables with related data. It defines how they're related and is
set on the relations node on a table element. When you create a relation on a table, you specify which field or
fields connect that table to another one. In the screen shot here, we have a relation. The name of it is EcoRes
product. And then the relationship itself is based on inventTable and the field called product within that table
and it relates to the EcoRes product table and the recID field within that table. Another example is that we can
have a customer table which has customer account number and general information about a customer such as
their name or location. Then we can have a customer group table which may have a list of customer account
numbers in one column and their corresponding groups in another. We can relate these tables on the
customer account number so that when we perform lookups in one table or another, we can find the related
records in each table. When creating forms, it's common to have related tables as underlying data sources.
These tables may be related in the query as well. We establish this relationship so that we can access
information in both tables by using a common field like account number or product. In addition to associating
rows in one table with another, relations can also be used to restrict the rows returned in a table and enforce
referential integrity. Let's take a look at some of the different relationship types and how they work in AX. The
first relationship type is called a normal relationship. A normal relation is used to specify a relation without any
conditions. In the field property, we select the field in the primary table that relates to a field in the present
table. In the related field property, we would then select a field in the related table. A field fixed relation is a
relation that's used to restrict records in the primary table. There's a field property which allows us to choose
which field in the primary table we want to use to restrict the records. There's also a value property where we
enter the value of a selected field to act as a filter. This relates only records in the primary table that match the
field value. Only numeric values can be entered in the value property. Field fixed relations can only be created
on numeric fields. Each of the related fields are ended in the table relation. They are combined. A related field
fixed relation is very similar to a field fixed relation except for it's used to specify the relation of the fields and
restrict records in a related table instead of the primary table. The same properties are used in set as in a field
fixed relation. We can only set a related field fixed relation on a numeric field as well. Another type of relation
is called a foreign key relation. This is used to specify a correspondence between a foreign key field in the
present table to the primary key field in another parent table. Foreign key relations are usually set on a child
table. We often refer to a child table as a table that has the foreign key. The on delete property value is
located within the relationship properties and it dictates what should happen when a deletion occurs. Since we
typically set the relation in the child table, the on delete property specifies what should occur when a related
record in a parent table is deleted. The purpose of this is to maintain database consistency when a record is
being deleted in a table that has related records in another separate table. There are four different properties
here that can be set on the on delete property. The first one is none. That means the row in this table is
deleted but nothing occurs to the tables that relate to this one. The second option is the cascade value for the
on delete property. And cascade means the row in this table will be deleted and all data in related tables will
also be deleted. The next value is called restricted. That means the row in this table will only be deleted if
there is nothing that relates to it in another table. This prevents deletion of a record that has related records
somewhere else in the system. The last option is called cascade restricted. The cascade restricted option
means to allow a cascade delete even though a record exists on related tables. This option causes a warning
box to appear to the user. If you click no, nothing will occur. If you click yes, then a cascade delete will run.
Module Review
In this module, we examined how relationships are used and the different types that exist in AX. We then
looked at some properties of relations and created a new relation for our vehicle maintenance and our vehicle
tables. Lastly, we reviewed some best practices to use when creating table relations.
Relations
About relations
Relation Types
Normal
On Delete Property
Outcomes
o None
o Restricted
o Cascade + Restricted
Best Practices
Configuration key specified for field in relation must be same key or in same tree of keys
MODULE PRACTICE
Practice 8: Create a Table Relationship
Scenario
Simon, the Systems Developer at Contoso, has identified that the vehicle table and the vehicle maintenance
table are related to each other by the vehicle ID field in both tables.
Each vehicle record in the vehicle table can be related to multiple maintenance records in the vehicle
maintenance table.
Module Review
Thank you for joining me in the module on form patterns. In this module, we looked at several examples of
different form patterns and sub-patterns as well as their applications in the form designer. We discussed the
important properties for form layouts and then we reviewed how to monitor the progress of a forms
development using the form statistics add-in and the form pattern tab.
Acquire target
Determine pattern
Apply pattern
Details master
Simple List
Table of Contents
Operational Workspaces
Sub-Patterns
Sub-Pattern Types
Image Preview
Selection Tiles
Layout Properties
Value: Auto
Value: View
Value: Edit
Form.RootDatasource.AllowCreate
Value
o No
o Yes
Allows creation
Form.RootDatasource.AllowDelete
Value
o No
Can’t delete
o Yes
Can delete
Ensures consistency
Form Statistics
Dialog shows
Module Review
In this module, we created some different types of forms to use in our fleet management system. We
discussed how forms are designed and the different types of controls that are used in the creation process. We
added data sources, controls, and elements to the form. Then we chose a pattern to apply and used the
pattern tab to help debug and guide the development process.
Form Controls
Form.Design
o Root of page
Group
Tab
TabPage
ButtonGroup
o ButtonGroup1
Button1
Button2
Types of Buttons
Button
Command Button
Menu Button
Toolbars
Grid Styles
Tabular Style
List Style
Add Elements
Best Practices
Name the form to coincide with the main data source table
For the Fleet Management System the user interface elements of the forms will need to be created. Following
the standard, there will need to be full entry data pages for both the Vehicle and Vehicle Management tables.
In addition, there will need to be a list page summarizing all of the Vehicles and link to the data pages.
Simon, the developer for Contoso, needs to create a list page form and supporting forms for the Vehicle and
Vehicle Maintenance information.
Display
Output
Action
o Specifies which form to use when form is opened from a menu item
Normal Image
o Specifies image used when menu item is associated with enabled button
control
Open Mode
Help Text
Label
Enum parameter
Create permissions
Delete permissions
Configuration key
Creating Menus
About Menus
Configuration Key
Normal Image
Label
MODULE PRACTICE
Practice 11.1: Create Menu Items
Scenario
For the Fleet management scenario, we will need to build menu items that point to the newly created forms.
Then we will build a menu to contain the top level form, the List page, and then link all of the menus using
Menu Extension to the existing menu structure of AX. Lastly, we will create menu item buttons for the Vehicle
and Vehicle Maintenance forms.
Lesson 4: Intellisense
In this lesson, we will discuss IntelliSense. IntelliSense is a predictive typing tool that aids developers during the
coding process. It prompts the user for known methods and possible choices of elements directly from the
AOT. IntelliSense also helps ensure that items are being consistently used within your code. It also helps
maintain consistent spelling of elements. The features of IntelliSense may vary depending on the version of
Visual Studio that you're running. So let's go ahead and demonstrate a little bit about how IntelliSense works
in the code editor. So I'm here in my runnable class dbHelloWorld that we saw output this hello AX world
message to the Infolog. Now, we can declare some objects to use within our code here at the beginning of our
static void main method. So I'll go ahead and begin typing. If I type the word C-U-S-T for cust, you'll notice
this popup appears with all these different objects in the system. This is IntelliSense kind of predicting what
we're typing. And if we scroll through, we can see there's many different objects. This little grid icon
represents a table. This CustAuditorTemp table. We have a lot of different classes. We also have extended
data types and enums would appear in this list as well. Anything that begins with cust. As I continue to type, it
will continue filtering down the list. So I can see if I typed a T, it recommends the cust table. So we can go
ahead and hit tab or click it from the list. And it will make that selection for us. And then we can go ahead and
give it a reference in our code. So let's see how it works with the base enum. So in our project, we have these
four base enums right now. And if I type DB, you can see it automatically makes that recommendation for the
dbDriveType enum. I'll hit tab to complete that selection. I'll give it an alias or a reference here to use
throughout my code followed by semicolon. And now I can begin using that enum in code. So if I type
dbDriveType, followed by two colons, IntelliSense will show me the values that are available of the different
element values for that enum. We configured this enum to have the following drive types. So when you are
using your base enuming code, you use the double colon to signify you want to choose the value for that
enum. So we can have something like this. Obviously maybe we'd have this in a more complex kind of if
statement to say if our drive type is four-wheel drive, then perform some other logic.
Module Review
In this module, we explored the code editor and created a runnable class. We then previewed how IntelliSense
works and introduced variable declaration. Next we reviewed basic syntax, keywords, and operators to use in
X++. We then discussed comparison tools and using the debugger in Visual Studio. Finally, we examined the
best practices to use when coding.
Code Editor
CIL can efficiently reference classes that are available in other .NET assembly DLL
files
Compiler
Standard compilation unit for X++ is same as other .NET languages, i.e. C#.
IntelliSense
Data Types
Anytype
Booleans
Dates
Enums
GUIDs
Integers
Reals
Strings
o Number of characters
TimeOfDay
Utcdatetime
Arrays
Containers
o All tables defined in the data base can be handled as class definitions
Benefits of EDTs
Properties set for EDT are used by all instances of that type, reduces work and
promotes consistency
Can create hierarchies of EDTs inheriting the properties that are appropriate from
the parent and changing other properties
Variable Declaration
Easier readability
Easier to find
Key Operators
Assignment operators
=
+=
++
-=
o Assigns the variable on left to the current variable value minus expression
on the right
--
Arithmetic Operators
<<
>>
*
/
DIV
MOD
~
&
^
|
o Binary OR: Performs binary or-operation
+
-
?
Relational Operators
Like
!
o Not
!=
#
&&
o Logical AND.
||
o Logical OR
<
o Less than
==
o Returns true if both expressions are equal
>
o Greater than
>=
Unary operators
o –
o ~
o !
o *
o /
o %
o DIV
o <<
o >>
o &
o ^
o +
o –
o |
Relational, equality
o <
o <=
o ==
o !=
o >
o >=
o Like
o As
o Is
o &&
o ||
Conditional
o ?:
Basic Syntax
Starting parenthesis on method declaration and calls should be the character just after
the method name (no space).
If there are one or two parameters, the parameters can be listed on the same line.
More than two parameters, move each parameter onto a new line, and indent by 4
spaces
Break up complex expressions that are more than one line – make it visually clear
Add one space between if, switch, for, while and the expressions starting parentheses.
Use braces around all code blocks, except for around case clauses in a switch statement
Basic Output
Create a box
If and if…else
Switch
While
Do while
For
Comparison Tools
Debugger
Infolog
Autos window
Naming Conventions
Code Placement
Comments
MODULE PRACTICE
Practice 12: Create a Runnable Class
Scenario
For the fleet management scenario, in the X++ code review we will need to create a static method in order to
familiarize ourselves with coding. Special attention in this module will need to be given to the code editor,
intellisense, syntax, and code statements in order to complete future scenarios.
Lesson 4: Methods
In this lesson, we will review methods. Method declarations consist of a header and a body. The method
header declares the name and return type of the method. The return type could be void which indicates that
there is no value being returned from that method. The method header also contains parameters and method
modifiers. The method body consists of variable declarations, method declarations, and code statements. Let's
review some of the main types of methods. A class declaration specifies the name of the class and the
necessary variables. It can also specify if inheritance is going to be used. Instance methods or object methods
are embedded in each object that is created from the class. They are called by using the syntax
objectname.methodname, and then followed by parentheses. You must instantiate the object before you can
use the method. Static methods are also known as class methods. And they belong to a class and are created
by using the keyword static. They are called by using the syntax class name colon colon method name and
then the parentheses. You do not need to instantiate an object before you use static methods. Static methods
are widely used in AX to work with data that is stored in tables. And lastly, we have main methods. A main
method is a class that is executed directly from a menu option. A good example of this is the static void main
methods we've been using in our runnable classes. The method should only create an instance of the object
and then call the necessary member methods. The underscore arch parameter allows you to transfer data to
the method. So I've added some code to our dbfmVehicleEntry base class that we created earlier in this
module. This code creates a dialog box or a quick entry kind of form that takes a user's input values and uses
them to insert data into the underlying table, so that eventually we can see that data on our VehicleListPage
form. So let's go through this code and see what's going on. We have our class called dbfmVehicleEntry. At
the beginning, we're creating a dialog object and we're creating dialog fields. Three of them. And then we're
also instantiating our dbVehicle table and giving it the reference called vehicle table. We have several methods
within this class. The first one here is the void method of main. Now, the main method instantiates our class
dbfmVehicleEntry and we're giving it a reference of a new name called VehicleEntry to be used within our code.
And then we set an equal to and we use the new operator which tells us to go instantiate a new instance of our
class, dbfmVehicleEntry, and then we call our class VehicleEntry.run. So we're calling the run method on our
own class here. So if we go down to the run method here on line 23, we can see it's a public method of type
void. The void indicates it does not return a value. It's just performing some logic here. We will discuss what
the public keyword means in the best practices lesson on this module. It's essentially a scope, so we're saying
that the variables and methods within this particular method can be accessed by outside classes and methods.
So the first thing this run method is doing in our class is calling another method called setupDialog. We use
this keyword to reference that the setupDialog method is in this class. So we call this .setupDialog. And our
setupDialog is located right here, and this method is also void, which means we're not returning any values.
What the setupDialog does is create the dialog box, the dialog window. And we have these three different
dialog fields that we created up here. They are all of the object type dialog field, simply with different names.
So we have three dialog fields, one for the vehicle make, one for the vehicle model, and one for the VIN
number. Now, we're using the dialog.add field and we're calling -- we're using the extended type of string. So
we're saying these DB VIN, make and model feeds are not extended data types of string. After the comma,
we're specifying what to put them -- what label value to supply for the dialog window for each of these fields.
So again, the field in parentheses is our actual field that we're using from our table, the DB make, the DB
model, and the DB VIN. OK. So if we go back to our run method, we'll continue walking through this step by
step. We have the dialog.run method which now runs our dialog. We have our three fields created on that
dialog window. And then we have the dialog.wait method which causes us to wait until we receive the user
input. Then we execute an if statement to say once the closed or OK button was chosen on the dialog, to go
ahead and execute this logic. So when the dialog has been closed and the values have been supplied, we call a
method called getFromDialog. And that method is right here. It's also a void method. Now, the
getFromDialog method, we're creating three string values within our code, make, model, and VIN, and we're
setting each of those to be equal to the value typed in on the dialog box in each of the respective dialog fields.
We then set our vehicle table buffer variable fields to be whatever the user typed in here in the dialog box.
And then when we go back up to our main method, or our run method, after the getFromDialog, the next line
of code is VehicleTableInsert. So then, we have these values passed in the dialog box. They've been assigned
to our buffer variable, our vehicle table, and now we're going to insert them with the vehicle table that insert
method command. And this is the insert method on the table. OK. So that's a quick walk-through of what
these different methods are doing. Let's go ahead and press CTRL F5 to run this and see how the dialog.entry
form works. So I'll go ahead and press CTRL F5 to build and run this class. Keep in mind, I have set this as my
startup class, or my startup object, so that when this project builds and executes, we will see the output from
this particular class. OK. So we verify that our build has been completed here. And we can go ahead and open
up our class runner window. And here, we have our quick VehicleEntry form with our three dialog fields that
the user can type in, supply values, and choose OK. And that's ultimately going to insert them into our vehicle
table. Now, we can see here in this void new method, we're setting the new dialog and then we're supplying
the label here and that's where we get in heading from. So let's go ahead and type some information in this
dialog box. Now, here, I have our VehicleListPage pulled up in the UI. I went ahead and just entered in some
random data here, just to give us something to look at. Then when we supply some values here on our dialog,
we should be able to see those appear then on our VehicleListPage. OK. So let's go ahead and just make up
some information, so we'll call this a Lincoln, and we'll call this an MKX. And we could just make up a number
for the VIN, and let's go ahead and hit OK. All right. Now, when we come to our list page over here and
refresh it, we should be able to see that record we just typed in the dialog be visible. OK. There it is at the
bottom of the table, we typed in Lincoln MKX. And this particular form actually does not show the VIN.
However, if we had that set up, then we would also see that value.
Module Review
Thanks for joining me in the classes module. We reviewed the structure of a class and the use of methods as
well as the different types of methods. We then demonstrated how a base class can use the concept of
inheritance, and then we created a child class to inherit from that base class. Finally, we reviewed the best
practices for using classes.
Class Structure
Class Construct
Blue print
Instance method
Work order
Useable code
Class declaration
Instance methods
Objective methods
Static methods
Class methods
Main methods
Class Inheritance
Objects created from Child have same methods and variable as Parent
Objects created from Child may have methods and variable that do not exist in Parent
Objected from Child may have methods from parent that are overridden or altered
Best practices
Clean up code
Protected
Private
Public
MODULE 13: YOUR NOTES
Module 14: Database Manipulation
Welcome to Module 14 on database manipulation. In this module, we'll cover how to use X++ code
statements to manipulate data in the database. The objectives for this module are to review the data retrieval
process, to demonstrate best practices to use when updating data, to explain the transaction integrity system,
and finally, to review how to update and delete data.
Module Review
Thanks for joining me in the database manipulation module. In this module, we covered how to retrieve and
review records. We explained the transaction tracking system and discussed the best practices to use when
updating data. Then, we reviewed how to insert, update, and delete data using X++ code.
MODULE 14 KEY TAKE AWAY
o Database Manipulation
Database Retrieval
Select statement
Fetching additional records with the “next” and “while select” statements
Loops over many records and can execute statements on each record
In a while select, the statement is executed only one time, immediately before the
first iteration of statements in loop
When performing data manipulation using the whole select statement, you
would typically do this in a transaction to ensure data integrity
Ttsbegin
Ttscommit
Ttsabort
Used as exception to abort and roll back transaction to state before ttsbegin
Data Insert
Only specified columns of rows selected by query are inserted into named table
Table columns being copied from and those of the table being copied to must by type
compatible
Data Updates
Update command modifies existing data in table with contents of table buffer
Before records can be updated, use “select forUpdate” to exclusively set record for
update
Data Deletion
Use this method, specify which rows are to be deleted by using a where clause.
Delete method can be overridden, for example, to add extra validation before records
are deleted.
MODULE 14: YOUR NOTES
Module 15: Exception Handling
Welcome to Module 15 on exception handling. The objectives in this module are to define the different
exception types, to discuss the key commands to use in X++ code, to review the code statements for exception
handling and to create a try/catch statement.
Module Review
Thanks for joining me in the exception handling module. In this module, we covered the different exception
types. We discussed the key commands in X++ to use with exception handling. We then reviewed some code
samples and demonstrated the functionality of a try/catch statement.
Exception Types
Info
Warning
Deadlock
Informs user that the system encountered a deadlock situation the database
Error
Numeric
Indicates an error has occurred during the use of str2int, str2int64 or str2num
functions
Dderror
Break
Internal
CLRError
CodeAccessSecurity
UpdateConflict
UpdateConflictNotRecovered
Key Commands
Try
Catch
Retry
Tells system to go back to Try statement and reattempt
Finally
Module Review
Thanks for joining me in the security basics module. We took a look at the architecture for authentication and
the security model in AX. We also looked at how to create new roles and duties from the Application Explorer
in Visual Studio. And lastly, we looked at key security related properties for buttons, table fields, form fields,
and menu items in AX.
Security Architecture
AAD redirects to AX
Security roles
o Determines duties user can perform and what they can view on interface
Process cycles
Duties
Privileges
Permissions
o Grants access to logical units of data and functionality
Query
Security policy
Context
Constrained tables
Role types
o Functional role
o Organizational role
o Application role
Button Properties
Needed permission
Needs record
Table Fields
Allow edit
Forms Fields
Allow edit
Needed permission
Mandatory
Menu items
Correct permissions
Create permissions
Delete permissions
Read permissions
Update permissions
o Specifies whether update permission will be able to select when privileges
are assigned to the menu item
MODULE 16: YOUR NOTES
Module 17: Introduction to Advanced Topics
In this module, we're going to introduce at a high level some of the more advanced features and capabilities of
AX. The objectives for this module are to review the business intelligence features, to review the reporting
framework, to explain the services and integrations, and to define and create data entities.
Module Review
Thank you for joining me in the introduction to advanced topics module. We reviewed some of the exciting BI
features like KPI modeling and integration with PowerBI. We then discussed reporting capabilities, financial
reporting, as well as services and other integrations. Finally, we reviewed types of data entities and their
different uses.
Business Intelligence
BI Features
Types of BI
Contextual BI
Embedded BI
Self-Service BI
Power BI Integration
Dynamics data
o Feeds
o Export
o Pre-built
Insights in Excel
o Discover
o Analyze
o Visualize
Collaborate in PowerBI.com
o Share
o Find
o Mobile
Embed in Dynamics
o Pin
o Launch
o Act
Reporting Services
Overview
Simplified administration
Development Process
Financial Reporting
Overview
Office Integration
Export to Excel
Workflows
Consistent processes
Process visibility
Data Entities
About
De-normalized View
Customer
o Account number
o Customer group
o Bank account
Party
o Party number
o Name
Address
o Postal address
o City
Electronic Address
o Phone
o Email Address
o Fax
Customer Entity
o Account number
o Customer group
o Bank account
o Party number
o Name
o Primary email
o Primary fax
Parameter
Reference
Master
Document
Transaction
Data Entity Use Cases
Synchronous services
Asynchronous integration
Data migration
Business intelligence