You are on page 1of 395

HOW TO USE RESOURCE MATERIALS TO TEACH THIS COURSE

As part of the Resource Materials there are several elements including; Student Online Companion Guide,
Instructor Presentation (PPT), Test Your Knowledge Questions (TYKQ’s) , and Lab/Practices. All of these materials
are for the instructor use, except for the Student Companion Guide, this is the students take away from this
course.

Instructor Notes:
The slide deck for this course is the primary guide for the instructor this will correspond to the companion guide
to some degree. However, the printed transcript may not align 100%. Suggestion would be to review this deck
and polish it to fit your needs. Practice the labs and demonstrations ahead of time, add own content to add
additional student value outside of the eLearning. However the two can be used in conjunction.

eLearning - You might choose to complement your classroom experience by leveraging various components of
the eLearning for this course. If you look within the notes of the PowerPoint slide deck for this course, you’ll find
the names of the various sections within the eLearning where each lesson and demonstration are covered. The
eLearning will cover the following topics:
Timeline – Total Course Duration: 20 Hours
Module Description Time to Complete
Introduction .5 Hour
1 Introduction to Visual Studio .5 Hour
2 Architecture 1 Hour
3 Labels and Resources 1 Hour
4 Base Enumerations 1 Hour
5 Extended Data Types  1 Hour
6 Tables  1 Hour
7 Table Indexes  1 Hour
8 Table Relations  1 Hour
9 Form Patterns  2 Hours
10 Form Creation  1 Hour

Timeline – Continued on next page


Timeline – Continued
Module Description Time to Complete
11 Menus .5 Hour
12 X++ Overview 2 Hours
13 Classes 2 Hours
14 Database Manipulation 1 Hour
15 Exception Handling 1 Hour
16 Security Basics 1 Hour
17 Introduction to Advanced Topics 1 Hour
18 Course Review .5 Hour
   
   
   
   
   
Total Class Presentation 20 Hours
Disclaimer: This courseware is provided “as-is”. Information and views expressed in
this courseware, including URL and other Internet Web site references, may change
without notice. Unless otherwise noted, the examples depicted herein are provided
for illustration only and are fictitious.  No real association or connection is intended
or should be inferred.  This courseware does not provide you with any legal rights
to any intellectual property in any Microsoft product. Complying with all applicable
copyright laws is the responsibility of the user. Without limiting the rights under
copyright, no part of this courseware may be reproduced, stored in or introduced
into a retrieval system, or transmitted in any form or by any means or for any
purpose, without the express written permission of Microsoft Corporation.
 
Copyright © 2015 Microsoft Corporation. All rights reserved.
 Microsoft®, Microsoft Dynamics®, Microsoft Dynamics® CRM 2015, Microsoft
Dynamics® CRM Online, Microsoft® SQL Server® data management software,
Microsoft Office® Outlook and Microsoft PowerPoint® are trademarks of the Microsoft
group of companies. All other trademarks are property of their respective owners.
80730: Development Basics
Mark White
November, 2015

Dynamics AX
Course Objectives
• Introduce Visual Studio development
environment and architecture.
• Create and customize elements.
• Create tables and define relationships
• Create forms, assign form patterns, and menus.
• Develop X++ code.
• Configure basic security.
• Introduce advanced topics.
Scenario
PROPOSAL – Fleet Management
System
• Make • Maintenance Type
• Model • Date of service
• Fuel Type • Hours
• VIN • Parts used
• And so on • Notes

Vehicle
Vehicle Table Maintenance
Table
Module 1
Introduction to Visual Studio
Module Objectives
• Configure the development environment.
• Define terminology and concepts.
• Demonstrate basic navigation.
• Create projects, models and packages.
• Create and use elements.
• Building elements.
Fleet Management Scenario

Configuration Element Build

Model &
Package Project
System Requirements

Can be hosted locally More RAM and CPU


Minimum: 16GB of
or in the cloud in cores translates to
RAM and 2 CPU cores
Microsoft Azure faster compiles
Demonstration
• Configuring Visual Studio for use with Dynamics
AX
Practice: 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.
Terminology and Concepts

Element
Models
s

Package
Projects
s
Projects, Models and Packages
Naming Conventions

Avoid
Using camel reserved
case words

Maintaining Prefix with a


consistency company
name or
project
name
Naming Conventions Examples

We will prefix our Development Basics elements with


“DB”, for example, we could name a table “DBVehicle”.

We will adhere to this prefixing convention when


creating additional elements for the Fleet Management
project, such as forms.
Navigation Areas
Application Explorer and AOT

Model View

Solution Explorer

Properties window

Code editor

Dynamics ‘AX 7’ Menu


Demonstration
• Demo the application explorer
Demonstration
• Demo the properties pane, solution explorer,
Dynamics ‘AX 7’ menu and code editor
Models

Overlayering
Creating a model Updating model
vs.
with the wizard parameters
Extension
Overlayering and Extensions

Overlayering
Extension model
(Customizations)
Demonstration
• Creating a model using the wizard
Demonstration
• Updating model parameters
Project Properties
Property Description
The type of object that will be used as the Startup Object when the project is run.
The following types are available:
Startup Object type Form
Class
Output menu item
Startup Object The object that will be invoked when the project is run.
Company The default company that will be used when the project is run.
Partition The partition that will be used when the project is run.
Project File The name of the file that contains information about the project.
Project Folder The location of the project.
The model that the project is associated with. All elements in the project must be
Model
in the selected model.
Model Publisher A read-only value that indicates the publisher of the model.
Layer A read-only value that indicates the application layer that the model is located in.

A value that indicates whether the synchronize operation for tables will be
Synchronize database on build
performed when the build action is performed for the project.
Demonstration
• Creating a new project to add to the Fleet
Management model.
Demonstration
• Importing and Exporting Projects
Practice: Create a Project
Scenario:
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
Elements

Element
designer

Finding Setting
related element
elements properties
Element Designer
Element Properties

Can be organized in
various ways

Contains details about the


highlighted, top-level node
Demonstration
• Opening the element designer and setting
properties
Practice: Create an Element
Scenario:
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.
Building operations
Metadata and
Best practices
X++ code
check
validation

Compilation
and creation Report RDL
of .NET generation
assemblies

Label and
Database
resource file
synchronization
generation
Demonstration
• Building and rebuilding a project
• Understanding build results
Practice: Build and Compile
Scenario:
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
Introduction to Visual Studio
Test Your Knowledge Question
1. TRUE OR FALSE. A Visual Studio project can
belong to more than one model.
a) True
b) False
Test Your Knowledge Question
2. What is a Dynamics ‘AX 7’ model?
a) A model is a Visual Studio project.
b) A model is a collection of elements (metadata/source
files) that represent a distributable software solution.
c) A model is a file used to deploy customizations to a
production environment
Test Your Knowledge Question
3. What does an element’s XML file contain?
a) Only metadata about the element
b) Only source code for the element
c) Metadata and source code for the element
d) Metadata and source code for the element and all
related elements
Test Your Knowledge Question
4. Which operation forces a build of all elements,
regardless of whether they have changed or not?
a) A project build
b) A model build
c) A rebuild
Test Your Knowledge Question
5. How can you visualize elements organized by
model (Model View)?
a) By going to the View menu on the toolbar and
choosing Model View
b) By right-clicking on the AOT node in the Application
Explorer and choosing model view
c) By right-clicking any model and choosing model view
d) By navigating to the ‘AX 7’ menu and choosing model
view
Module 2
Architecture
Module Objectives
• Describe the elements included in the
application stack.
• Review the server architecture.
• Explain the cloud architecture used with
Dynamics AX.
Application Stack

Fleet
Application Suite
Management

Application Foundation

Organization Number Global Address Source


Model Sequence Book Documents

Application Platform

Runtime & Data Workflow & Client &


SSRS Reporting
Access Services Presentation
Server Architecture
UI Interaction Layer OData Endpoint
(WCF) (WCF)

Forms Engine

Metadata Security Caches

Workflow Batch

Aggregate Data
Data Access Layer Data Store base
Server Architecture

The server, including the In the cloud, it is deployed


application code base, is to Azure Infrastructure as a
deployed to an IIS web service (IaaS) Virtual
application. Machines.
Server Architecture

Model stores are


represented as a set
of folders and XML
artifacts.

Organized by model.
Cloud Architecture
Lifecycle
Services

Cloud
Architecture

Shared Dynamics
services AX
Microsoft Azure
Module Review
Architecture
Test Your Knowledge Question
1. Which of the following is NOT a model in the
application stack?
a) Application Foundation
b) Application Core
c) Application Suite
d) Application Platform
Test Your Knowledge Question
2. TRUE or FALSE. Model stores are represented
as a set of folders and XML artifacts.
a) True
b) False
Test Your Knowledge Question
3. Lifecycle Services and Microsoft Azure are
services that relate to which architecture
component in Dynamics AX?
a) Server Architecture
b) Application Stack
c) Virtual Architecture
d) Cloud Architecture
Module 3
Labels and Resources
Module Objectives
• Learn about labels in AX
• Review the purpose of labels for Fleet
Management.
• Create and use both label files and labels.
• Explore the search capability of the label editor.
• Review best practices for labels.
• Learn about resources.
• Create and use resources.
About Labels

Label files are small data structures that


keep all related and new labels in a
central storage file.

Labels themselves are a reference from


the element or artifact that point back
to the label file.
Fleet Management Labels

Create a
Label
File

Create
labels
when Build
needed
Demonstration
• Create a label file and a label
Demonstration
• Search Labels
Best Practices for Labels

Ensure that
labels contain
Use labels for
appropriate
every element
translation of
or artifact
activity or
item

Use labels Create a label


when file with the
programming same name as
for all external the associated
strings model
Practice: Create Labels
Scenario:
• 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.
About Resources

Icons

Visual
Pictures
representations

Resources
Create and Use Resources

Add Select Change


Solution
New Item Resource Name of
Explorer
to Project File Resource
Demonstration
• Create and Use Resources
Module Review
Labels and Resources
Test Your Knowledge Question
1. Resources in Dynamics AX are primarily which
of the following?
a) System memory and CPU
b) A data structure that stores textual information
c) Part of a label file
d) Pictures or icons stored in the system
Test Your Knowledge Question
2. TRUE or FALSE. Labels can have multiple
versions depending on language settings.
a) True
b) False
Test Your Knowledge Question
3. Which scenario best describes when labels
should be created and used?
a) For all elements that you create
b) Only elements that need additional clarity
c) Only for elements that will be used across companies
d) Mainly for elements that are used with multiple
languages
Module 4
Base Enumerations
Module Objectives
• Define a base enumeration.
• List examples of base enumerations.
• Create new base enumerations.
• Review best practices for base enumerations.
Fleet Management Scenario

Create a Set the


labels on
base the Build
enumeration elements

Set the Create the


label Elements
About Base Enumerations

0 = Value A
1 = Value B
2 = Value C
3 = Value D

Base Enumeration Examples

Sales
No/Yes order
status

ABC Posting
Codes types
Demonstration
• Open the Project.
• Create a new base enumeration.
• Set key properties on the base enumeration.
Practice: 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
Practice: 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 dbfmVehicleType dbfmFuelType


None Car Gas
Registration Truck Diesel
OilChange Van Propane
Maintenance SUV Natural Gas
Repair Electric
Best Practice Considerations

Consider the length

Consider if it should be mandatory

Consider if it is a special type

Consider if you want a default value

Consider data if deleting an enumeration or value


Best Practices
• Always let the constant be an enumerator.

• Never use numeric constants instead of enums.

• Never use other constants instead of enums.

• Do not make Boolean tests on enum fields.

• Never use relational operators on enums.

• Never compare or assign to enums of different types.

• Do not expect the enumerators to have a numeric value in the range of 0.


Module Review
Base Enumerations
Test Your Knowledge Question
1. How are base enumerations represented and
stored in the database?
a) As a literal string value
b) As a numerical value
c) As an alphabetical character
d) None of the above
Test Your Knowledge Question
2. TRUE or FALSE. The first literal value or option in
an enumeration is internally represented by the
number 1.
a) True
b) False
Test Your Knowledge Question
3. Which of the following are examples of field
types where a base enumeration should be used?
(Select three that apply)
a) A posting type field
b) A transaction date field
c) A sales order status field
d) ABC Codes to rate customers, vendors or items
Module 5
Extended Data Types
Module Objectives
• Review the primitive data types with AX.
• Create new extended data types.
• Describe best practices for data types in AX.
Scenario

Determine
Configure
primitive properties Build
data type

Create an Set the


Extended Label
Data Type Value
Possible EDTs for Fleet Management
Type Field Description Type Field Description
Date Year of the vehicle Integer Seating capacity
Date Inspection date Integer Mileage
Enum Third row check box Integer Vehicle ID
Enum Fuel type String Make
Enum Vehicle type String Model
Enum Service type String Note
Real Fuel level String VIN number
String Engine description
Primitive Types
Type Description
Anytype A placeholder for any data type
Booleans Can only contain the values false and true.
Dates Contains day, month, and year.
Enums An abbreviation for enumerated text—a set of literals.
GUIDs A globally unique identifier.
Integers A number without a decimal point. To declare an integer, use the keyword
int.
Real Numbers with a decimal point; also called decimals.
String A number of characters. To declare a string, use the keyword str.
TimeOfDay Contains hours, minutes, and seconds. To declare a time, use the system
type timeOfDay.
UTCDateTime Contains year, month, day, hour, minute and second.
Benefits of EDTs

The
Code is
properties
easier to
are
read
inherited

Provide
Reduce
consistenc
work
y
Demonstration
• Create a new string and review key properties
• Create a new date and review key properties
• Create a new integer and review key properties
• Create a new real and review key properties
• Create a new enum and review key properties
• Extend an existing EDT and override key
properties
Best Practices

Use EDTs whenever Create one for each


Pass the “is a” test
possible atomic entity

Do not directly use


Only create
the system data
subtypes when
type for recID or
they are needed
tableID
Best Practices for EDT Properties

Following naming standards

Use labels for all user interface text

The help text should not be the same as the label

Leave the display length and style as Auto when possible

Specify the enum type for all enums


EDTs for Fleet Management
Type Name Field Description
Date dbfmYear Year of the vehicle
Date dbfmInspectDate Inspection date
Date dbfmServiceStartDate Service start date
Date dbfmServiceEndDate Service end date
Enum dbfmThirdRowCode Third row check box
Enum dbfmFuelTypeCode Fuel type
Enum dbfmVehicleTypeCode Vehicle type
Enum dbfmServiceType Service type
Real dbfmFuelLevel Fuel level
EDTs for Fleet Management
Type Name Field Description
Integer dbfmGrossVehicleWeight Gross vehicle weight
Integer dbfmNumberofDoors Number of doors
Integer dbfmSeatingCapacity Seating capacity
Integer dbfmMileage Mileage
Integer dbfmVehicleID Vehicle ID
String dbfmMake Make
String dbfmModel Model
String dbfmNote Note
String dbfmVIN Vehicle Identification Number
(VIN)
String dbfmEngineDescription Engine description
Practice: Create Extended Data Types
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.
Module Review
Extended Data Types
Test Your Knowledge Question
1. TRUE OR FALSE. Extended Data Types (EDTs)
are based on primitive data types and also have
additional properties set.
a) True
b) False
Test Your Knowledge Question
2. TRUE OR FALSE. You should use extended data
types whenever possible.
a) True
b) False
Test Your Knowledge Question
3. Whichof the following are benefits of using
EDTs? (Select all that apply)
a) They are more easily compiled and transferrable
b) Reusability
c) Code is easier to read
d) Inherited properties and consistency
Module 6
Tables
Module Objectives
• Create a table to store information.
• Add data types to the table.
• Extend a table using inheritance
• Set key properties for a table.
• Create a temporary table.
• Create a query based on a table.
• Review best practices for tables.
Scenario

Create a
table to Adds EDTs
Build
Add Set
store key (fields) datasources Properties
information

Set Create
Set labels
properties Queries
Set Title Build
About Tables
Stores business
transactions and Made up of
metadata used in records (rows)
the system

Name Category
Aaron Boy
Susan Girl
Derek Boy
Layla Girl
Tyler Boy
James Boy
Table Components
Demonstration
• Open the Fleet Management Project.
• Add a new table to the project
Demonstration
• Add elements to the newly created table
About Field Groups

Types of field
groups

Common uses for


field groups

Best practice
checks for field
groups
Demonstration
• Create a field group
• Add fields to the field group by drag and drop
• Add fields to the field group by right-clicking
Practice: 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.
Key Table Properties

Table Type Label PrimaryIndex

Support
ConfigurationKey ClusterIndex
Inheritance

Extends
Table Inheritance

Controlled by the Support Inheritance


and Extends table properties

Allows for sharing attributes or fields


from a base table
Example of Table Inheritance
Consider the following three tables:
Demonstration
• Open Fleet Management project
• Open the Application Explorer and find the table
you want to extend
About Temporary Tables

Defined by the Table


Commonly used for
Two main types: Type property value on
reporting
the table properties
• TempDB
• InMemory
About Queries

May
contain
one or Highly
more flexible
tables as a
data source

Can specify Reusable


details at on forms
run time and reports
Demonstration
• Create a query
• Add a data source
Practice: Create Queries
• Scenario:
In addition, each of the tables will need a query to
return the data for forms and reports.
Table Best Practices
• Naming • Table group

• Labels
• Table types
• Form reference

• Created and
• Title fields modified fields
Best Practices for Table Fields

Table ID and Record IDs

Memo and Container fields

Consider mandatory, allow edit on create, allow edit and


visible properties carefully.

Always use EDT or enums


Best Practices for Field Groups

Use field
Use field
groups to
groups to
organize
design
related
forms
fields

Auto
Auto report
lookup
should have
reverts to
at least two
TitleField1
fields
and 2
Query Best Practices

Use queries
Create queries in Always use
instead of select
the Application queries as the
statements when
Explorer instead data source for
structure of
of X++ code Forms and
“select” is
when possible Reports
unknown
Module Review
Tables
Test Your Knowledge Question
1. Which two key properties work together to
control table inheritance?
a) The Support Inheritance and Table Type
properties
b) The Table Type and Extends properties
c) The Extends and Support Inheritance properties
d) The Allow Inheritance and Extends properties
Test Your Knowledge Question
2. What are the two main types of temporary
tables?
a) Regular and TempDB
b) Inherited table and TempDB
c) Regular and InMemory
d) InMemory and TempDB
Test Your Knowledge Question
3. TRUE or FALSE. If a modification is made to a
field group, such as a new field being added, any
forms that contain that field group will
automatically update to reflect the new addition.
a) TRUE
b) FALSE
Test Your Knowledge Question
4. What kind of data can found in the tables in
Dynamics AX? (Select two that apply)
a) Aggregated analytical data
b) Metadata, such as system settings
c) Business and transaction data
Test Your Knowledge Question
5. TRUE or FALSE. Queries are reusable elements
that can contain only one table as a data source.
a) TRUE
b) FALSE
Module 7
Table Indexes
Module Objectives
• Define the types of table indexes.
• Provide examples of each type.
• Create new table index.
Scenario

Creat
e Set
Parameters Build
Table

Plan Index Add Index


Index Types

Primary Index

Clustered
Index
Non-
Clustered
Index
About Indexes

Indexes are associated with tables and make it easier to find specific
data

Defined by one or more fields on a table

Improve performance of data retrieval

Can ensure existence of unique records


Demonstration
• Open the Fleet Management project and model
• Open the application explorer and locate the table
in question
• Open the table designer and create the index
Practice: 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.
Best Practices
Always maintain indexes in the development
environment

Always specify a clustered index

Always specify a primary index

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 Review
Table Indexes
Test Your Knowledge Question
1. TRUE OR FALSE. The order of the columns in an
index is not important.
a) True
b) False
Test Your Knowledge Question
2. TRUE or FALSE. It is a best practice to always
specify a clustered index.
a) TRUE
b) FALSE
Test Your Knowledge Question
3. Which of the following are valid types of table
indexes used in Dynamics AX? (Select three that
apply).
a) Primary Index
b) Partial Index
c) Clustered Index
d) Non-clustered Index
Module 8
Table Relations
Module Objectives
• Define the different types of table relations.
• Define the On Delete property.
• Create new table relation.
• Review the best practices for table relations.
Scenario

Creat
e Build
Set
Relation
parameters

Table

Add Add
Index(es) Relations
About Relations
Relations are defined between tables with related data

Relations are set on the relations node beneath a table element

Useful for performing lookups for forms

Enforce referential integrity


Relation Types

Field
Normal fixed
relation

Related
Foreign
field
Key
fixed
relation
relation
On Delete Property

Cascad
e

de Re
a
sc cted st ri c
a
C tri ted
e s
R
Demonstration
• Open the Fleet Management project and model
• Locate the FMVehicleMaintenance table from your
project
• Open the table designer and create a relation
Practice: 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.
Best Practices

Name of relation should contain the name of the table it relates to

A relation should be defined on the table holding the foreign key

The configuration key that is specified for the field in a relation must be the same key,
or in the same tree of keys, as the key used for the related field.

When using navigational relationships, the Validate property must be set to “No”
Module Review
Table Relations
Test Your Knowledge Question
1. Which of the following values for the On Delete
property for a relation specifies to only permit
deletion of records in a table when there is nothing
that relates to it in another table?
a) Restricted
b) Cascade
c) Cascade + Restricted
d) None
Test Your Knowledge Question
2. TRUE or FALSE. It is a best practice to define the
relation on the table holding the Foreign Key.
a) True
b) False
Test Your Knowledge Question
3. Which two of the following types of relations can
only be created on numeric fields?
a) Normal relation
b) Field fixed relation
c) Related field fixed relation
d) Foreign Key Relation
Module 09
Form Patterns
Module Objectives
• Illustrate form pattern examples.
• Run the form patterns report.
• Apply patterns to forms.
• Apply sub patterns to form controls.
• Define important properties.
About Form Patterns

Provide many default


control properties

Allow for guided


development

Create consistency and


ensure better
compatibility with
upgrades
Steps for Applying Patterns

Acquire Determin Apply Deal with


Target e Pattern Pattern Errors
Form Pattern Types

Simple List
Table of
Form Part Contents
Fact Boxes (Setup
Page)

Form
Details Operational
Master Pattern Workspaces
s
Demonstration
• Run Form Patterns report
• Locate forms with certain patterns or no
patterns applied.
Demonstration
• Show a Details Master form in UI
• Show in Form Designer
Demonstration
• Show Fact Box in UI
Demonstration
• Show Simple List pattern type in UI
Demonstration

Show Table of Content (Setup Pages) in UI


Demonstration
Show Operational Workspace form in UI
Sub-patterns

Controls may
Applied in a
Can be added be prefixed
similar manner
to various form with “Pattern:
as Form
controls <unspecified>”
Patterns
after the name
Sub-pattern Types

e Fiel
ag
Im iew Fiel ds and
dG
Prev rou
ps
ers

Se Tiles
m
Filt

lec
sto

tio
Cu
k)
uic

n
(Q
Demonstration
• Show examples of Custom Filters
Demonstration
• Show image preview and field and field groups
sub patterns in UI and development
environment
Demonstration
• Show examples of section tiles sub-pattern
Demonstration
• Locate a control with an unspecified sub-pattern
• Apply an appropriate sub-pattern
Form Properties
Property Value Description

Page opens in View mode, and has an Edit button that toggles to
Done, Save, and Restore. Be aware that some page styles ignore
Form.Design.ViewEditMode Auto
the ViewEditMode property. For example, a dialog box doesn’t
use the ViewEditMode property.

The page opens in View mode and has no buttons that are
Form.Design.ViewEditMode View
related to editing the page. The page is “always view.”

The page opens in Edit mode, and has Save and Restore buttons.
Form.Design.ViewEditMode Edit
The page is “always editable.”
Form Properties
Property Value Description

The page is effectively a read-only data source.


Form.RootDatasource.AllowCreate No
It has no New and Delete buttons.

Form.RootDatasource.AllowCreate Yes The page allows creates. It has a New button.

The page doesn’t allow deletes. It has no Delete


Form.RootDatasource.AllowDelete No
button.

Form.RootDatasource.AllowDelete Yes The page allows deletes. It has a Delete button.


Demonstration
• Go over design properties and layout
About Form Pattern Tab

Notifies user of
Allows for guided Ensures
errors and areas in
development consistency
need of correction
Form Statistics

• Summary of
form statistics
Dialo • Form pattern
g that name
shows • Percentage of
: controls that are
covered by the
pattern
Form Pattern Tab
Module Review
Form Patterns
Test Your Knowledge Question
1. TRUE or FALSE. Form patterns are applied to
a form’s design node, while form sub-patterns
are applied to certain form controls.
a) True
b) False
Test Your Knowledge Question
2. Which form pattern contains a vertical
arrangement of tabs and is commonly used for
Setup pages?
a) Simple List
b) Details Master
c) Operational Workspaces
d) Table of Contents
Test Your Knowledge Question
3. The Form Statistics dialog shows which of the
following pieces of information (select all that
apply):
a) The name of the applied form pattern
b) The pattern coverage percentage
c) The number of controls covered by a pattern
d) Total count of controls
Test Your Knowledge Question
4. TRUE or FALSE. The form patterns report is
a .csv file that is generated by Visual Studio.
a) True
b) False
Module 10
Form Creation
Module Objectives
• Create a form.
• Add data sources to a form.
• Define important form controls.
• Add controls and data types to a form.
• Apply patterns and sub-patterns to forms and
controls.
Scenario

Create
a form
Apply a
Pattern Build

Add a
Configure Data
Source
Demonstration
• Open the Fleet Management project
• Add two forms to the project
Practice: Create Forms
Scenario:
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.

This practice and the next will cover this scenario.


Form Design Layout
Container Description
The root of the page. It functions as a special kind of
Form.Design
container.
The general-purpose container control in Microsoft
Group
Dynamics AX. Group controls can be nested as required.

A control that contains TabPage controls and has many


Tab possible Tab.Style values, such as Tab, FastTab, Vertical
Tab, Droplist and Panorama.

The appearance of each TabPage control depends on its


TabPage
Tab.Style value.

ButtonGroup A special type of Group control that contains buttons.


Demonstration
• Demonstrate different tab styles
Action Pane Tab
Action Pane Hierarchy
• ActionPane
• ActionPaneTab1
• ButtonGroup1
– Button1
– Button2
Types of Buttons
Button

Command Button

Menu Item Button

Drop Dialog Button

Menu Button
Toolbars

Toolbar represented by Add, Edit, Map buttons

Previously known as “Action Pane Strip”


Grid Styles
Tabular Property Style
Style Style=Auto Tabular grid

Style=Tabular Tabular grid


List Style
Style=SimpleReadOnly Simple read only

Simple
Read Only Style=List List grid
Grid Style Examples

Tabular Style Grid

List Style Grid Simple Read Only Style Grid


Demonstration
• Add a data source to a form and apply pattern
Demonstration
• Adding controls and fields
Demonstration
• Add controls for the List Page form
• Follow the pattern tab to ensure all controls are
added in the correct order
• Drag data types from the data source to the
Grid control
Practice: Adding Elements
Scenario:
This practice is in continuation from the previous
practice.
Form Design Best Practices

Name the
Use the Use the Try to cover
form to
“Auto” and Form all controls Avoid
coincide with
“Default” Statistics with the placing code
the main
properties add-in for applied on forms
data source
for sizing guidance pattern
table
Module Review
Form Creation
Test Your Knowledge Question
1. TRUE or FALSE. Button groups can be placed
directly underneath the Action Pane control on a
form.
a) True
b) False
Test Your Knowledge Question
2. Setting the Grid Style property value to “Auto”
defaults to what type of Grid Style?
a) List Style
b) Simple Read Only Style
c) Tabular Style
d) Details Style
Test Your Knowledge Question
3. TRUE or FALSE. The Pattern tab in the pattern
information panel provides the developer with
guidance in terms of which controls are required,
and in what order. If a control for a particular form
pattern is missing or in the wrong order, the build
operation will still allow the user to run and view
the form in the currently developed state.
a) True
b) False
Test Your Knowledge Question
4. TRUE or FALSE. A form must have a form pattern
applied.
a) True
b) False
Test Your Knowledge Question
5. When all requirements for a form pattern have
been satisfied, what must be done first before
building and previewing the form in a browser
window?
a) Run the forms pattern report
b) Check the forms statistics add-in
c) Set the form you want to preview as the Start
Up object for the project
d) A rebuild of the form
Module 11
Menus
Module Objectives
• Review how to create and use menu items.
• Create menus and attach menu items.
Fleet Management Scenario

Menu Menu Menu


Item parameters
extension

Menu item
parameters Menu Menu
item Build
buttons
About Menu Items

Display

Output

Action
Key Property Values on Display Menu Items

Form View
Option

Normal Image

Open Mode

Help Text

Label
Key Property Values on Output Menu Items

Enum
Enum
Type
Parameter
Parameter

Linked Linked
Permissio Permissio
n Object n Type
Key Property Values on Action Menu Items

Create Permissions

Delete Permissions

Extended Data
Security

Configuration Key
Demonstration
• Create a Menu Item
Practice: 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.

This practice and the next will cover this scenario.


About Menus
Key Property Values on Menus

Menu Item Menu Item


Type Name

Configuration Normal
Key Image

Label
Demonstration
• Create Menu
• Extend a Menu
• Test a Menu
Demonstration
• Update Forms with Menu items
Practice: Create a Menu
Scenario:
This practice is a continuation of the previous
practice.
Module Review
Menus
Test Your Knowledge Question
1. Suppose you want to attach an SSRS report
to a menu item, so that when a user clicks the
menu item, the report will display. Which type
of menu item should be used for this purpose?
a) Display
b) Action
c) Output
d) Window
Test Your Knowledge Question
2. TRUE or FALSE. Menus are prebuilt to include all
of the accessible items in AX from the Navigation
Pane, however, you can also add your own.
a) True
b) False
Module 12
X++ Overview
Module Objectives
• Explore the code editor.
• Review the controls of the compiler.
• Create a runnable class.
• Review IntelliSense feature for coding.
• Introduce variable declaration.
• Review basic syntax.
• Identify key words and operators.
Module Objectives
• Review the comparison tools
• Demonstrate how data types are used in code.
• Discuss the use of the debugger.
• Review code best practices.
Fleet Management Scenario

Create
a Class
Build Test

Set as
Input
Startup
Code
Object
Visual Studio Environment
Benefits of X++ Code and .NET CIL
CIL runs much faster in most scenarios. In cases where there are many method
calls, and a lot of algorithmic content (as opposed to database access), you can
expect significant performance improvements.
• It is easier to write application logic in other managed languages.
• Dynamics AX assemblies can be consumed directly.
• The preferred way of consuming business logic in Dynamics AX externally is by using services.

CIL can efficiently reference classes that are available in other .NET
assembly DLL files.

CIL can be operated on by the many excellent .NET tools.


Compiler

The X++ compiler has been rewritten from


scratch. No backward-incompatible changes
have been introduced to X++.

An X++ best practice tool has also been


implemented. It allows the addition of user-
defined custom rules.
Complier

The standard
compilation unit for
X++ is the same as
for other .NET
languages such as C#.
Demonstration
• Create a Runnable Class (A Static Main Method)
Practice: 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.
IntelliSense

Prompts the
Predictive Helps
user for Ensures that
typing tool of maintain Varies with
known items are
the elements consistent version of
methods and consistently
directly from spelling of Visual Studio
possible used
the AOT elements
choices
Demonstration
• Demo intellisense
Primitive Data Types
Anytype A placeholder for any data type.
Booleans Can only contain the values false and true.
Dates Contains day, month, and year.
Enums An abbreviation for enumerated text—a set of literals.
GUIDs A globally unique identifier.
A number without a decimal point. To declare an integer, use
Integers
the keyword int.
Reals Numbers with a decimal point; also called decimals.
A number of characters. To declare a string, use the keyword
Strings
str.
Contains hours, minutes, and seconds. To declare a time, use
TimeOfDay
the system type timeOfDay.
utcdatetime Contains year, month, day, hour, minute and second.
Composite Data Types

X++ composite data types Description


An array is a list of items with the
Arrays same data type and the same name—
only the index differs.
A container is a dynamic list of items
Containers containing primitive data types and/or
some composite data types.
A class is a type definition that
Classes as Data Types describes both variables and methods
for instances (objects) of the class.
All tables defined in the database can
Tables as Data Types
be handled as class definitions.
Extended Data Types
• User Defined
types
Extendedtyp
Extended
= e Variable { , 
• Additional
declaration
Variable } ; name and
Identifier
properties
Variable =
[ option ] • Declaration
arrayoptions
and syntax to
Option =
| initializatio the left
n
Benefits of EDTs

The properties you set for an EDT


Code is easier to read because
are used by all instances of that
variables have a meaningful data
type, which reduces work and
type.
promotes consistency.

You can create hierarchies of


EDTs, inheriting the properties
that are appropriate from the
parent and changing the other
properties.
EDT Code Sample

class DevBasicsEDTSample
{
public static void main(Args _args)
{
DBVehicleType vehicleType;
vehicleType = ‘Truck’;
info(vehicleType);
}

}
Variable Declaration

Declare variables Declare variables Var keyword is Assign a value to


in small scopes prior to using available to infer a field inline with
• Easier readability them in an the type the declaration
• Is within the block of executable • used for declaration • reduces code lines
code that you are statement of local variables • improves readability
using
• Scoped closer to use • must be clear for of assignment
• Easier to find inferred type in
initialization
Demonstration
• Demo var keyword
Assignment Operators

Operator Description
Assigns the expression on the right of
= the equal sign to the variable on the
left.
Assigns the variable on the left the
+= current variable value plus the
expression on the right.
++ Increments the variable by one.
Assigns the variable on the left the
-= current variable value minus the
expression on the right.
-- Decrements the variable by one.
Arithmetic Operators
Operator Term Description
Performs expression2 left shift (a multiplication by 2) on
<< Left shift
expression1.
>> Right shift Performs expression2 right shift (a division by 2) on expression1.
* Multiply Multiplies expression1 by expression2.
/ Divide Divides expression1 by expression2.
DIV Integer division Performs an integer division of expression1 by expression2.
Returns the remainder of an integer division of expression1 by
MOD Integer remainder
expression2.
~ Not Unary operator. Performs a binary not-operation.
& Binary AND Performs a binary and-operation on expression1 and expression2.
Performs a binary XOR-operation on expression1 and
^ Binary XOR
expression2.
| Binary OR Performs a binary or-operation on expression1 and expression2.
+ Plus Adds expression1 to expression2.
- Minus Subtracts expression2 from expression1.
Takes three expressions: expression1 ? expression2 : expression3.
? Ternary operator If expression1 is true, expression2 is returned; otherwise,
expression3 is returned.
Relational Operators
Operator Description
like Returns true if expression1 is like expression2.
! Not.
!= Inequality operator (not equal to).
# Prefix on macro names.
&& Logical AND.
|| Logical OR.
< Less than.
== Returns true if both expressions are equal.
> Greater than.
>= Greater than or equal.
Order of Operator Precedence

Operators in precedence order Syntax


unary operators -~!
multiplicative, shift, bitwise AND,
* / % DIV << >> & ^
bitwise exclusive OR
additive, bitwise inclusive OR +–|
relational, equality < <= == != > >= like as is
logical operators (AND, OR) && ||
conditional ?:
Basic Syntax

In Visual Studio the methods start with one tab. Everything


within the method starts at two tabs.

The starting parenthesis on method declarations 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. If there are more than two parameters,
move each parameter onto a new line, and indent by 4 spaces.
Basic Syntax
Break up complex
Only one statement expressions that are Use a single blank line
per line. more than one line - to separate entities.
make it visually clear.

Add one space


Do not use Do not use between if, switch, for,
parentheses around parentheses around while and the
the case constants. where expressions. expressions starting
parentheses.

Use braces around all


Use braces even if
code blocks, except for
there is only one
around case clauses in
statement in the block.
a switch statement.
Basic Output

Create a
Create an
Create a Box Dialog
Info log
Button
Output Syntax
Box Info Log
info("Information notice to the
Box::info(“Body text”, “title”, interface");
“Help text”);

warning("Warning notice to the


Box::warning("This posting needs interface");
receiving first.", "warning title",
"Help text");
error("Error notice to the
interface");
Output Syntax
• Dialog

DialogButton dialogButton;

dialogButton = Box::yesNoCancel ("Do you want to


continue?",DialogButton::Yes,"Inquire","Help text");
Supported Statements and Loops
if and if…else

Switch

While

Do while

For
If..else and Switch Statements
int oilchange = 3;
int oilchange = 3;
str answer;

if(oilchange >=2)
switch(oilchange)
{
{
info("Repeat customer");
case 1:
}
answer = "First time customer";
break;
else
case 2:
{
answer = "Repeat customer";
info("New customer");
break;
}
default:
answer = "Frequent customer";

break;
}
info(strFmt(answer));
While and For
While Example For Example
int counter1 = 0; for (int counter2 = 0; counter2
!=4; counter2++)
while (counter1 != 4) {
{ info(strFmt("counter2 is %1",
info(int2Str(counter1)); counter2));
counter1++; }
}
Demonstration
• If…else and Switch statements using pervious
code.
Demonstration
• Demonstrate While:

int counter1 = 0;

while (counter1 != 4)
{
info(int2Str(counter1));
counter1++;
}
Demonstration
• For loop
Comparison Tools

Old
Original
Code

New
Import
Code

Merged
Results
Code
Debugger
Debugger
Debugger
Debugger
Best Practices
Naming Conventions

Code Placement

Comments

Variable declaration within scope

Header Comments using ///


Module Review
X++ Overview
Test Your Knowledge Question
1. What are the three main Object-Oriented
Programming components? (Select all that
apply)
a) Classes, objects, tables
b) Classes, methods, objects
c) Methods, variables, classes
d) Methods, objects, variables
Test Your Knowledge Question
2. What is the VAR keyword used for in X++?
a) To define a variable that can change data types
b) To define a variable of no specific data type, the
compiler will determine
c) To define an array type variable
d) To define a container
Test Your Knowledge Question
3. What are the three types of messages in an
Infolog?
a) Info, Warning, and Error
b) Info, Box, and Warning
c) Dialog, Box, Error
d) Info, Dialog, Box
Test Your Knowledge Question
4. Where can variables be declared in X++?
a) Only at the beginning of a method
b) Only at the beginning of a class
c) Anywhere in the code (“in-line”)
d) It must be defined somewhere within a class
declaration
Test Your Knowledge Question
You have the following X++ statement:
 
For(int counter = 1; counter<10; counter+=3)
{
Info(strfmt(“%1”, counter));
Counter--;
}
 You need to identify the output of the statement. 
5. What should you identify?
a) 1, 3, 5, 7, 9
b) 1, 4, 7, 10
c) 0, 3, 6, 9
d) 0, 1, 3, 6, 9
Module 13
Classes
Module Objectives
• Review the structure of classes.
• Demonstrate the use of methods.
• Create a base class.
• Review the concepts behind class inheritance.
• Create an inherited class.
• Review the best practices for classes.
Fleet Management Scenario

Create a Create an
Base Extended
Class
Build

Class

Build Test Test


Class Structure

• Blue Print • Now you can use


• Work Order
Class
• Defines the Instance
• Constructs the Useable
the house
Construct
construction of the method house code
• When done, it goes
building away
Demonstration
• Create a base class to add to project
Create a Base Class TYKs
1. You are to complete the code needed to create a
class. Your class will not return information. Which
will best complete this statement.
class __________ myClassName
a) void
b) null
c) str
d) return
Create a Base Class TYKs
2. You are to complete the code needed to create a class. You need
to instantiate a class. Which will best complete this statement.
dbfmVehicleEntry vehicleEntry = __________ dbfmVehicleEntry();
a) instantiate
b) new
c) public
d) return
Create a Base Class TYKs
3. You are to complete the code needed to create a
class. You need to assign a value. Which will best
complete this statement.
vehicleTable.dbMake ______ Make;
a) =
b) +=
c) ==
d) =+
Key Methods

Class
Instance
Declaratio
Methods
n

Static Main
Methods Methods
Demonstration
• Demonstrate the Key Methods
Class Inheritance

Objects created from the Child have the same methods


and variables as the Parent.

Objects created from the Child may have methods and


variables that do not exist in the Parent.

Objects created from the Child may have methods from


the Parent that are overridden or altered, in the Child.
Class Inheritance

Parent Class – InventType


canInventBeReserved palletTagging doScrap

Child Class - InventTypeCustom


doScrap palletTagging updateTrucklist
Demonstration
• Class Inheritance
Class Inheritance TYKs
4. You are to complete the code needed to create a class with inheritance.
What is the command to return information from the parent class? Which will
best complete this statement.
{
_____________();
~~~Body of new code here~~~
}
a) insert
b) return
c) extends
d) super
Class Inheritance TYKs
5. You need to create inheritance within the classes.
Which will best complete this statement.
class dbfmTruckVehicleEntry __________
dbfmVehicleEntry
a) void
b) return
c) extends
d) super
Class Inheritance TYKs
6. You are to complete the code needed to create a class with inheritance. You would like your
method accessible to other classes. Which will best complete this statement.
____ void getFromDialog()
{
~~~Body of code ~~~
super();
}
a) public
b) Private
c) protected
d) void
Best Practices
Have only one successful return point in the code

Keep the building blocks (methods) small and clear

Do put braces around every block of statements, even if there is


only one statement in the block.

Do put comments in your code

Do not assign values to, or manipulate, actual parameters that are


"supplied" by value.

Clean up your code; delete unused variables, methods and classes.


Variable and Method Declaration

Protecte
d

Private

Public
Module Review
Classes
Test Your Knowledge Question
1. Which type of class should be created in order to
test code?
a) Runnable class
b) A normal class
c) A static class
d) A public class
Test Your Knowledge Question
2. What is the reserved word in a function that is
used when the method does NOT return a value?
a) Static
b) Null
c) Void
d) Private
Test Your Knowledge Question
3. Which keyword is used in the class declaration to
specify class inheritance? This allows one “child”
class to inherit the methods and variables of
another “parent” class.
a) Inherits
b) Extends
c) Supports
d) Follows
Test Your Knowledge Question
4. TRUE or FALSE. Using the “Private” keyword for
variables or methods allows access to those
variables from within the current method as well as
subclasses.
a) True
b) False
Test Your Knowledge Question
5. TRUE or FALSE. If a child class inherits variables
and methods from a parent class, those methods
cannot be altered or changed in the child.
a) True
b) False
Module 14
Database Manipulation
Module Objectives
• Review data retrieval process.
• Demonstrate best practices when updating data.
• Explain the transaction integrity checking
system.
• Review how to update and delete data.
Fleet Management Scenario
View Build Test

Build
Update Delete

Test
Test Build

Insert Build Test


Data Retrieval

Returning data for view is a common feature

You will need to read records from the database

Single calls can be possible for uniquely index tables

More effective searches iterate over the whole table to


ensure no item is missed
Select Statement

Using a table variable


Using the “select”
with a select
statement
statement

Fetching additional
Results of a select
records with the
statement are
“next” statement and
returned in a table
“while select”
buffer variable.
statements
Select Statement Syntax
SelectStatement = select Parameters
[ [  FindOptions  ] [  FieldList 
Parameters from ] ] TableBufferVariable [ IndexClause ] [  Options  ] [  Whe
reClause  ] [  JoinClause  ]

crossCompany | reverse | firstFast | [ firstOnly | firstOnly10 |


firstOnly100 | firstOnly1000 ] | forUpdate | noFetch |
FindOptions =
[forcePlaceholders | forceLiterals] | forceselectorder |
forceNestedLoop | repeatableRead | validTimeState

FieldList = Field  { ,  Field  } | *


Field = Aggregate  (  FieldIdentifier  ) |  FieldIdentifier
Aggregate = sum | avg | minof | maxof | count

[ order by , group by ,  FieldIdentifier  [ asc | desc ] { ,


Options =
 FieldIdentifier  [ asc | desc ] }] | [  IndexClause  ]

WhereClause = where  Expression


JoinClause = [exists | notexists | outer ] join  Parameters
While Select Statement

while select loops over many records (meeting certain


criteria) and can execute a statement on each record.

In a while select, the select statement itself is executed


only one time, immediately before the first iteration of
the statements in the loop.

When you perform data manipulation by using the while


select statement, you would typically do this in a transaction
to ensure data integrity.
Sample While Select Statement

CustTable custTable;
DirPartyTable dirPartyTable;

while select dirPartyTable order by Name


join custTable
where custTable.Party == dirPartyTable.RecId
{

info(dirPartyTable.Name+', '+custTable.AccountNum);
}
Demonstration
• While Select Statement
Demonstration
• Show view records example
Reading Records TYKs
1. You are to complete the code needed to read
records. Which will best complete this statement.
While _________ fmVehicleMaint join fmVehicle
a) select for update
b) select
c) order by
d) select into
Reading Records TYKs
2. You need to find the equivalent value in the second table. Which will best
complete this statement.
where fmVehicle.dbVehicleID _________ fmVehicleMaint.dbVehicleID

a) =+
b) =
c) !=
d) ==
Reading Records TYKs
3. You need to output the code to the screen. Which will best complete this statement.
_________(Int2Str(fmVehicleMaint.dbVehicleID)+', '+fmVehicle.dbMake);

a) info::box
b) info
c) warning
d) print
Transaction Integrity Checking

ttscommit – Indicates
ttsabort – Used as an
the successful end of a
ttsbegin – Indicates the exception to abort and
transaction. This ensures
beginning of the roll back a transaction to
the transaction
transaction. the state before the
performed as intended
ttsbegin.
upon completion.
Data Insert

Only the specified The columns of the


columns of those table being copied
rows selected by from and those of
the query are the table being
inserted into the copied to must be
named table. type compatible.
Sample Insert Statement
InventItemPriceToleranceGroup inventItemPriceToleranceGroup;

ttsBegin;
inventItemPriceToleranceGroup.itempricetolerancegroupid = '4%';
inventItemPriceToleranceGroup.name = 'TelevisionSeriesOne';
inventItemPriceToleranceGroup.insert();

inventItemPriceToleranceGroup.itempricetolerancegroupid = '6%';
inventItemPriceToleranceGroup.name = 'TelevisionSeriesTwo';
inventItemPriceToleranceGroup.insert();
ttsCommit;

info("Yahoo!");
Demonstration
• Insert Statements
Demonstration
• Insert Records into Fleet Management tables
Data Insert TYKs
4.You are to complete the code needed to insert records. You need to finish
the transaction. Which will best complete this statement.
{
ttsbegin;
~~~Body of code here~~~
_________________
}
a) ttsabort;
b) insert;
c) escape;
d) ttscommitt;
Data Insert TYKs
5. You are to complete the code needed to insert
records. You need to format the date. Which will
best complete this statement.
fmVehicle.dbYear = __________(01/01/2008);
a) datepart
b) Mkdate
c) sysdate
d) datename
Data Insert TYKs
6. You are to complete the code needed to insert
records. Which will best complete this statement.
fmVehicle.______________
a) insertrecord();
b) insertall();
c) insert();
d) insertnow():
Update

The Update command Before records can be


The new values are then
modifies existing data in a updated, use “select
committed to the database
table with the contents of using the update() method.
forUpdate” to exclusively set
a table buffer a record for update.
Sample Update Statement
InventTable inventTable;
InventItemGroupItem inventItemGroupItem;

ttsBegin;
while select forupdate inventTable
exists join inventItemGroupItem
where InventItemGroupItem.ItemId == inventTable.ItemId
&& InventItemGroupItem.ItemGroupID == 'TV&Video'
{
inventTable.ItemPriceToleranceGroupId =“7%";
inventTable.update();
  info("this works!");


ttsCommit;
Demonstration
• Update a record in the Vehicle table
Data Updates TYKs
7. You are to complete the code needed to update
records. Which will best complete this statement.
while select _______ fmVehicle
a) read
b) forupdate
c) lock
d) fetch only
Data Updates TYKs
8. You are to complete the code needed to update
records. You would like find the equivalent value.
Which will best complete this statement.
where fmVehicle.dbVehicleID ________ 1
a) ==
b) =
c) +=
d) !=
Data Updates TYKs
9. You are to complete the code needed to update records. You need to assign the value.
Which will best complete this statement.
{
fmVehicle.dbModel _______ "Yaris";
fmVehicle.update();
}

a) ==
b) =
c) +=
d) !=
Data Deletion

To use this method, specify which


rows are to be deleted by using a
Deletes the current record from the
where clause. Records are then
database.
removed, one at a time, from the
specified table.

The delete method can be


overridden, for example, to add extra
validation before records are deleted.
Sample Delete Statement
InventTable inventTable;
InventItemGroupItem inventItemGroupItem;

ttsBegin;
while select forupdate inventTable
exists join inventItemGroupItem
where InventItemGroupItem.ItemId == inventTable.ItemId
&& InventItemGroupItem.ItemGroupID == 'TV&Video'
{
inventTable.delete();

info("this works!");
}
ttsCommit;
Demonstration
• Delete Statement
Data Deletion TYKs
10. You are to complete the code needed to delete
records. Which will best complete this statement.
while select __________ fmVehicle
a) delete
b) fetch
c) lock
d) forupdate
Data Deletion TYKs
11. You are to complete the code needed to delete
specific records. Which will best complete this
statement.
_________ fmVehicle.dbVehicleID == 2
a) orderby
b) join
c) where
d) from
Data Deletion TYKs
12. You are to complete the code needed to delete records. Which will best complete this
statement.
{
fmVehicle.________();
}

a) drop
b) kill
c) deletefrom
d) delete
Module Review
Database Manipulation
Test Your Knowledge Question
You have tables named salesTable and salesLine.
The salesTable contains the following data: The salesLine table contains the following information:
SalesID RecID SalesID RecID

01 SO0001 1234567 01 SO0003 2234567


02 SO0002 1234568 02 SO0002 2234568
03 SO0003 1234569 03 SO0003 2234569

You need to identify the output of the X++ statement:


 
01 SalesTable salesTable;
02 SalesLine salesLine; 1. What should you identify?
03 ;
   
04 while select salesTable
05 order by salesLine.Recid desc a) SO0001 SO0002 SO0003
06 join salesLine
07 where salesLine.salesId == salesTable.salesid b) SO0002 SO0003 SO0003
08
09 { c) SO0003 SO0002 SO0003
10 info(strfmt("%1",salesTable.salesId));
11 } d) SO0002 SO0002 SO0003
Test Your Knowledge Question
2. What are the three keywords associated with
the Transaction Tracking System?
a) ttsBegin
b) ttsCommit
c) ttsEnd
d) ttsCommence
e) ttsAbort
Test Your Knowledge Question
3. You need to fetch data from CustTable in ascending order based
on City. CustTable contains a field named City. There is a non-unique
cluster index named cityIdx on the City field. What are three possible
statements that achieve the goal?
a) Select custTable index cityIdx;
b) Select custTable order by city;
c) Select custTable order by city ASC;
d) Select custTable index city;
Test Your Knowledge Question
4. TRUE or FALSE. When performing a data
insert, the insert() command inserts the
contents of a table buffer.
a) True
b) False
Test Your Knowledge Question
5. TRUE OR FALSE. The Update command
modifies existing data in a table with the
contents of a table buffer.
a) True
b) False
Module 15
Exception Handling
Module Objectives
• Define the different exception types.
• Discuss key commands.
• Review code statements for exception handling.
• Create a Try/Catch statement.
Fleet Management Error Handling

Create Catch
Errors Build
Class

Add Add
Try/Catch TTSBegin Test
Block TTSCommit
Exception Types
info: Displays deadlock: Informs the user
warning: Indicates the user error: Indicates a fatal
informational exceptions; that the system
has performed an illegal, error has occurred and the
for example, a certain encountered a deadlock
though nonfatal operation. transaction has stopped.
record has been updated. situation in the database.

numeric: Indicates that an


Internal: Displays
error has occurred during dderror: Indicates that an
break: Indicates that the Microsoft Dynamics AX
the use of the str2int, error occurred in the
user has pressed Break. internal development
str2int64, or str2num DDkernel class.
errors.
functions.

UpdateConflictNotRecov
UpdateConflict: Indicates
CodeAccessSecurity: ered: Indicates that an
CLRError: Indicates that an that an error has occurred
Indicates that an error has error has occurred in a
error has occurred during in a transaction using
occurred during the use of transaction using
the use of the CLR Optimistic Concurrency
CodeAccessPermission.de Optimistic Concurrency
functionality. Control, and that the
mand. Control, and that the code
transaction will be retried.
will not be retried.
Key Commands

Try Catch

Finall
Retry
y
Code Statements – Part 1
class CustCreateCustomer
{

static void main(Args _args)


{
CustCreateCustomer custCreateCustomer = new
CustCreateCustomer();

custCreateCustomer.run();
}
Code Statements – Part 2
public void run()
{
Dialog dlg = new Dialog("Create new customer");
DialogField dlgCust;
DialogField dlgGrp;
CustTable custTable;
dlgCust = dlg.addField(extendedTypeStr(CustVendAc), "Customer account");
dlgGrp = dlg.addField(extendedTypeStr(CustGroupId));

if (dlg.run())
{
try
{
custTable.AccountNum = dlgCust.value();
custTable.CustGroup = dlgGrp.value();
Code Statements – Part 3
if (!custTable.validateWrite())
{
throw error("Please enter all required fields.");
}
else
{
custTable.insert();
}
}
catch (Exception::Error)
{
error("An error occurred. Please try again");
}
Demonstration
• Invalid VIN: Error thrown.
Demonstration
• Validated VIN
Code Statements TYKs
1. You are to complete the code needed to start exception
handling. Which will best complete this statement.
____________________ error("Please enter a valid VIN
number.");
a) exception
b) catch
c) throw
d) info
Code Statements TYKs
2. You are to complete the code needed to catch
an exception. Which will best complete this
statement.
catch (_________________________)
a) exception::error
b) error
c) ttsAbort
d) dialog::error
Code Statements TYKs
3. You are to complete the code needed to execute
exception handling. You need to display this
message. Which will best complete this statement.
___________("An error occurred. Please try again");
a) info::exception
b) catch
c) error
d) dialog::error
Module Review
Exception Handling
Test Your Knowledge Question
1. The statements provided in the “finally” clause
are executed irrespective of whether the try block
threw any exceptions.
a) True
b) False
Test Your Knowledge Question
2. Which of the following is NOT a valid exception
type?
a) Info
b) Deadlock
c) Stop
d) UpdateConflict
Test Your Knowledge Question
3. TRUE OR FALSE. The “throw” statement initiates a
ttsAbort command.
a) True
b) False
Test Your Knowledge Question
4. You need to validate the date and throw an error if the date entered is null or greater than
current system date. Which of X++ statements should you use?
a) If(InputDate != datenull()) c) If(InputDate != datenull())
{ {
Throw error(“Wrong selection of date”); Throw error(“Wrong selection of date”);
} If(inputDate > systemDateGet())
Else If(inputDate > systemDateGet()) {
{ Throw error(“Wrong selection of
Throw error(“Wrong selection of date”); date”);
} }
}

b) If(InputDate == datenull() || inputDate > d) If(InputDate != datenull())


systemDateGet()) {
{ Throw error(“Wrong selection of date”);
Throw error(“Wrong selection of date”); }
} If(inputDate > systemDateGet())
{
Throw error(“Wrong selection of date”);
}
Module 16
Security Basics
Module Objectives
• Review the security architecture.
• Explain role based security.
• Describe security elements in the Application
Explorer.
• Modify and create security in the Application
Explorer.
• Describe the Extensible Data Security Framework
and how to use XDS policies.
Authentication for the User Interface

1. Sign-in via AAD (can be multi-factor AuthN) 2. AAD redirects to ‘AX 7’ 3. ‘AX 7’ start page displayed
Authentication for Services

Apps granted delegated access (but don’t get to see credentials)


Apps that consume AX web services

AX
App Server
AX web services (OAuth)
Security Structure in AX
Security Authorization and Access Control
Security Authorization and Access Control
Extensible Data Security Framework

Security Constrained
Query Context
Policy Tables
Role Design Principles

Role segregation
categories
Role types.

Users are assigned


to one or more
roles according to
Roles account for their job.
the organization
size, culture and
Roles represent the industry focus.
common access
rights that are
required for the job
positions within an
organization.
Demonstration
• Create a role in the Fleet Management Project
• Add existing duties to the role.
• Add existing privileges to the role.
Demonstration
• Create a duty for the Fleet Management Project.
• Add privileges to the new duty.
• Add the duty to the Role Created earlier.
Button Properties

Needed Needed
Needs
Access Permissio
Record
Level n
Table Fields

Allow edit
Allow edit
on create

Minimum
Mandator
read
y
access
Form Fields

Allow Edit

Needed
Mandatory
Permission
Menu Items

Correct Create Delete


Permissions Permissions Permissions

Linked Linked Linked


Permission Permission Permission
Type Object Child Object

Read Update
Permissions Permissions
Module Review
Security Basics
Test Your Knowledge Question
1. TRUE OR FALSE. All users must be assigned at
least one security role in order to access AX.
a) True
b) False
Test Your Knowledge Question
2. If the property value for the Needed Permission
property on a form control is set to “Create”, which
other permissions does this level allow?
a) It only allows create access.
b) It allows create and read access only.
c) It allows create, read, and update access.
d) It allows create and delete access.
Test Your Knowledge Question
3. TRUE or FALSE. Roles themselves are specific to a
company or organization.
a) True
b) False
Test Your Knowledge Question
4. Which of the following are examples of a
privilege? (Select the two that apply)
a) Being a system administrator
b) Canceling a payment
c) Managing system security
d) Processing deposits
Test Your Knowledge Question
5. Which two of the following choices can be
assigned to a role?
a) Privileges
b) Permissions
c) Configuration Keys
d) Duties
Module 17
Introduction to Advanced Topics
Module Objectives
• Review Business Intelligence features.
• Review reporting framework features.
• Explain services and integrations.
• Define and create Data Entities.
BI Features

In-memory aggregate models

Aggregate data entities

Aggregate programming model

Aggregate measurements and


dimensions

New KPI modeling


Types of BI

Contextua Embedde Self-


l BI d BI Service BI
Power BI Integration
• Integration with PowerBI.com cloud service:
• Data refresh and mobile access
Power BI Integration
• Embed directly in AX

PowerBI.com Dashboard and Tiles Dynamics AX rich client (Browser)


Reporting Services Overview

Services
hosted in
Microsoft Simplified
Azure development
Compute
service

Simplified Enhanced
administration report viewing
Development Process
Create reporting project in Visual Studio

Edit report in Visual Studio

Add report to menu item

Set menu item as start up object

Deploy report to server

Use CTRL + F5 to verify the report


Advantages of SSRS Reports

Built-in back-office
document
management
capabilities

Parameterized views
Precision documents
and drill-through
to comply with local
navigations to other
regulatory business
AX pages and other
practices.
reports.
Financial Reporting
22 default
financial
reports

Users can edit


or create new
reports

Requires proper
privileges and
duties
Service and Integrations Overview
Open Data Protocol (Odata) V4

Provides a simple
and uniform way to Supports
share data in a Enables broad consumption in
discoverable integration across PowerBI.com as a
fashion. products. refreshable data
• Uniform URL source
conventions
Office Integration

Excel Data
Export to
Connector
Excel
app
Workflows

Consistent
processes

Centralized Process
work list visibility
About Data Entities
De-normalized
view of database
tables

Replace
Provides single
diverging
stack to capture
concepts of DIXF
business logic
entities

Provide primary
mechanism to
extract/insert
data sets
De-normalized View
Data Entity Categories

Parameter
Reference
Master
Document
Transaction
Data Entity Use Cases

Synchronous Asynchronou
services s integration

Data Business
migration Intelligence
Creating Data Entities

Add new data


entity to a project Build entity directly
and follow the from a table
wizard
Module Review
Introduction to Advanced Topics
Test Your Knowledge Question
1. TRUE OR FALSE. In memory, real-time aggregate
models will now be used for analytical purposes,
instead of SQL Server Analysis Services Cubes.
a) True
b) False
Test Your Knowledge Question
2. TRUE or FALSE. Tiles and charts created on
PowerBI.com can be pinned directly into AX.
a) True
b) False
Test Your Knowledge Question
3. In order to view one of the default financial
reports, such as a Balance Sheet. What needs to be
configured first?
a) Fiscal calendar and currency
b) Chart of accounts
c) Ledger
d) Proper security for the end-user
Test Your Knowledge Question
4. Which of the following are true about data
entities? (Select the three that apply).
a) They provide a de-normalized view of tables
b) Can be leveraged for Business Intelligence and
Data Migration purposes
c) They are a normalized view of the data.
d) Enable Synchronous services (APIs) to be
exposed on them
Test Your Knowledge Question
5. What are some of the benefits of using the
OData v4 protocol? (Select the three that apply)
a) Broad integration across platforms
b) Data migration
c) Supports consumption of data using Power BI
d) Uniform URL conventions
Module 18
Course Review

You might also like