You are previewing Mastering Microsoft Dynamics AX 2012 R3 Programming.
O'Reilly logo
Mastering Microsoft Dynamics AX 2012 R3 Programming

Book Description

A comprehensive guide to developing maintainable and extendable solutions with Microsoft Dynamics AX 2012 R3

  • Design and build software solutions quickly and efficiently, exceeding customer/user expectations

  • Build well thought out data structures utilizing various key features of Dynamics AX

  • Use this practical programming tutorial to create compelling user interfaces, allowing users to adopt them easily

  • In Detail

    Due to its interesting capabilities such as finance and supply chain management, business intelligence and reporting, project management, and so on, Microsoft Dynamics is one of the most widely used solutions adopted by many organizations across the globe. This book is a step-by-step tutorial that covers elements from the initial design through to development. Each concept is fully explained and demonstrated by the creation of a real-world project. You will learn some really useful, advanced development techniques such as extending your code with metadata and exception handling.

    This book is an invaluable tutorial if you are moving from another ERP system or language, or if you are a technical consultant with a desire to create efficient functional designs and business solutions.

    What You Will Learn

  • Acquaint yourself with the decision-making process to create robust technical solutions

  • Design extendable data structures using appropriate technologies

  • Create code that is reusable from the start, and avoid time-consuming code refactoring

  • Understand how and why form logic is separated into interaction classes

  • Create code that is extendable by other parties, without modifying your code

  • Understand the importance of using patterns and frameworks

  • Test and debug your code to check functionality and performance efficiency

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. Mastering Microsoft Dynamics AX 2012 R3 Programming
      1. Table of Contents
      2. Mastering Microsoft Dynamics AX 2012 R3 Programming
      3. Credits
      4. About the Authors
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
          3. Instant updates on new Packt books
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Preparing Our Solution
        1. The technical architecture of a solution
          1. Data structures
          2. The user interface
          3. Application logic
        2. Minimizing the footprint of changes
          1. Where to make the change
          2. The use of field groups
          3. Eventing
            1. Event subscription
            2. Delegates
          4. Extending a class
          5. Table-level form events
        3. Selecting the appropriate layer for our solution
        4. Configuring source control
          1. Configuring AX to use MorphX VCS
          2. Configuring AX to use Team Foundation Services
            1. Using Visual Studio Online with AX CU7 or prior
            2. Creating a new TFS project using Visual Studio Online
            3. Configuring AX version control parameters to connect to TFS
            4. Troubleshooting
        5. Creating the models
          1. ISV models
          2. VAR models
          3. Customer or end user models
          4. Creating the models
        6. Creating a label file
        7. Creating a project
        8. Setting up the default project and model
        9. Designing the technical solution
          1. Data structure design considerations
            1. Extended data types
            2. Base enums – enumerated types
            3. Tables
            5. Maps
          2. Classes
          3. Forms
        10. Designing test plans
        11. Summary
      9. 2. Creating Data Structures
        1. Designing the data structures for our solution
        2. Creating labels
        3. Creating the setup tables
          1. Creating the vehicle group table
            1. Creating extended data types
            2. Creating the table
              1. Adding fields to the table
              2. Creating field groups
              3. Creating indexes
              4. Adding the find and exist methods
            3. Completing the primary key EDT
            4. More on indexes
          2. Creating the vehicle service schedule table
        4. Creating enumerated types
        5. Creating the vehicle table
          1. Creating the enumerated types for the vehicle table
          2. Creating the table that supports inheritance
            1. Completing the table relations
            2. Completing the vehicle table
          3. Creating the inherited tables
            1. More on the InstanceRelationType property
        6. Creating the vehicle service data table
        7. Referential integrity – delete actions and validation
          1. How this works
        8. Summary
      10. 3. Creating the User Interface
        1. Creating a menu structure
          1. Customizing an existing menu
        2. Understanding the patterns used in interface design
          1. Form structure
        3. Creating setup forms
          1. The vehicle group form
            1. Creating the menu item
          2. The vehicle service data form
        4. Creating the vehicle list page
          1. Creating the Details form
          2. Creating the list page interaction class
          3. Creating the base query for the list page
          4. Creating the list page
        5. Investigating form events
        6. Taking more control over the form layout
        7. Creating the vehicle create form with the handler class
        8. Summary
      11. 4. Creating Business Logic and Hooking into Core AX
        1. Moving table validation and logic into a class
          1. Implementing the pattern
          2. Adding validation logic
          3. Adding business logic
            1. Checking whether the record has a service schedule
            2. Getting the service schedule record
            3. Creating the NextServiceDate and NextServiceOdo methods
          4. Testing
        2. Adding navigation
          1. Adding the ability to create a service record for a vehicle
          2. Initializing the service record from the vehicle record
            1. Creating the initFrom method
            2. Modifying the form handler to store a vehicle record
            3. Modifying the service details form to detect whether it was called with a vehicle
            4. Modifying the form handler to initialize from the vehicle
          3. Viewing vehicle service records for a vehicle
        3. Number sequences
          1. Defining a number sequence
          2. Configuring the table to automatically apply the number sequence
        4. Hooking into standard AX logic using event handling
          1. Associating the appointment with a vehicle
            1. Adding custom fields to the appointment table
            2. Creating a class to handle the modifiedField event
            3. Creating the event handler method
            4. Adding a subscription to TMSAppointmentTable.modifiedField
            5. What happens when the code executes
          2. Creating a delegate for use by other parties
        5. Summary
      12. 5. Adding Business Intelligence
        1. What are parts?
        2. Creating info parts to show key business data
          1. Creating a query for the part
          2. Creating the info part
          3. Creating the part's menu item
          4. Adding the info part to the All loads list page
          5. Completing the info part
        3. Creating a form part
          1. Creating the form for the form part
          2. Creating the form part reference
          3. Creating the menu item and associating it with the vehicle table
        4. Creating cues and cue groups
          1. Creating the service history cue
          2. Creating a Preview part for the cue
          3. Creating an appointment cue
        5. Using form parts on a form
          1. Creating a view to aggregate the data for the form part
            1. Creating a query for the view
            2. Creating the view using the query as a data source
          2. Creating the query for the form part
          3. Creating the form for our form part
          4. More on queries and forms
          5. Creating links between forms programmatically
        6. Summary
      13. 6. Extending the Solution
        1. Adding secondary list pages
          1. Adding a list page for active vehicles
          2. Adding a list page for inactive vehicles
        2. Using menu items to change the vehicle status
          1. Creating the data contract class
          2. Creating the class to process the update
          3. Database transactions
          4. Adding further validation to the status change
          5. Hooking up the code with the interface
            1. Creating the menu item handler class
            2. Creating the menu items
            3. Adding the menu items to the list page
        3. Adding a drop dialog to change vehicle group
          1. Creating a drop dialog form
        4. Exposing the vehicle group logic as a custom web service
          1. Creating the service class and service
          2. Creating the Visual Studio test project
          3. Creating a service method to change the vehicle group
            1. Getting information from the infoLog object
            2. Creating the updateVehicleGroup service method
            3. Updating the Visual Studio service test project
          4. Creating a service method to return a list of vehicle groups
            1. Creating a utility method to convert an AifQueryCriteria object to a Query object
            2. Creating a vehicle group data contract
            3. Creating the service method
            4. Using the new service within the Visual Studio test project
        5. Summary
      14. 7. Designing Your Security Model
        1. Setting up license and configuration keys
          1. Legacy security features
        2. Designing the security structure
          1. Impact on licensing
          2. Designing the security structure
        3. Creating privileges
          1. How privileges affect security and user experience
          2. Hiding buttons that the user has no access to
          3. Refining access to the data
          4. Providing access to services
          5. Server methods
        4. Creating duties
        5. Creating roles
          1. Testing the security roles
          2. The relationship between client security tools and the AOT
        6. Providing access to server methods – code permissions
          1. Code access permissions for a privilege
          2. Creating a code permission
        7. Designing and creating process cycles
        8. Restricting access to data using policies
        9. Summary
      15. 8. Customizing Standard AX
        1. Key goals when customizing standard or third-party code
        2. How to determine where to make the change
          1. Cross-reference data
            1. Cross reference – Used by
            2. Keeping the cross-reference data up to date
            3. Cross reference – Using
          2. Type hierarchy
        3. Adding fields to tables
          1. Field groups
        4. Integrating a custom module with standard AX
          1. Adding the vendor ID reference to the vehicle table
          2. Marking a vendor as a vehicle service provider
          3. Reference group controls
          4. Creating a custom lookup for reference group controls
            1. Creating a custom lookup for standard fields
            2. Adding a method to state whether this is a vehicle service provider or not
          5. Using event handlers to reduce footprint on standard AX
        5. Using an extension table for additional fields
        6. Changing the behavior of a class
        7. Extending a framework – vendor electronic payments
        8. Summary
      16. 9. Advanced Features and Frameworks
        1. Adding custom filters to list pages
        2. Advanced methods of adding ranges to list pages
        3. Using the SysOperation framework
        4. Using the SysOperation framework execution modes
          1. Executing code asynchronously
          2. Executing code using the batch framework
          3. Last value and usage data
          4. Handling the result of a task processed asynchronously
          5. References
        5. Customizing the user interface displayed by the SysOperation framework
        6. Tracking progress of scheduled tasks
        7. Understanding the global address book
          1. Electronic addresses
          2. Postal addresses
          3. Creating addresses programmatically
        8. Accessing the financial dimension framework
          1. References
        9. Summary
      17. 10. Advanced Development Techniques
        1. Making data date-effective
        2. Utilizing metadata within AX
          1. Accessing the data model using metadata
          2. Accessing code using metadata
        3. Making your code extendable with metadata
          1. Interfaces
          2. Sample solution using metadata
            1. The design
            2. Creating a utility class
            3. Creating the interface class
            4. Creating the user interface
            5. Creating the form control definition contract class
            6. Creating the form builder class
            7. Updating the vehicle table form
          3. Taking this further
        4. Exception handling
          1. Handling general exceptions
          2. Handling CLR exceptions
          3. Handling table update exceptions
        5. Controlling how and where code is executed
          1. Constructing code on a specific tier
          2. Passing data between client and server
          3. Serializing classes using the SysPackable interface
          4. Executing code in CIL
        6. Code access permissions
          1. File I/O permission
          2. The CLR interop permission
        7. More on views – computed columns
          1. How SQL Server executes views
          2. Adding a computed column
            1. A note on performance of computed columns
            2. Creating a computed column – concatenating two fields
          3. Creating a computed column – return data from related tables
          4. Other useful functions
          5. Common misconceptions
        8. Summary
      18. 11. Unit and Performance Testing
        1. Unit testing
          1. Code review
          2. Test-driven development
        2. Using the debugger
        3. Automated unit testing
          1. Creating automated unit test cases
            1. Creating the unit test project
            2. Creating a unit test case
            3. Running the unit test case
        4. Creating unit tests with data isolation
          1. Setup and teardown of test data
        5. Reviewing the results of the unit test
        6. Code and database performance testing through code profiling
          1. Interpreting the results
          2. Enabling SQL execution plans
          3. Investigating the performance of views
          4. References
        7. Summary
      19. A. Efficient Design and Development with Microsoft Dynamics AX
        1. The technical overview of Dynamics AX
          1. The model store database
          2. The compiler and CIL
        2. Layers and models
          1. Layers
          2. Models
        3. The MorphX IDE
          1. AOT
          2. Saving your work
          3. The Projects window
        4. The options for source control
        5. General development practices
          1. Naming
          2. Commenting
          3. Editor scripts
        6. Patterns and frameworks
          1. Patterns
          2. Frameworks
      20. B. Using Version Control
        1. When to add to version control
        2. Working with version control
          1. Adding a model to version control
          2. Managing AOT elements with version control
          3. Version control options
            1. Changes
            2. Pending Objects
            3. Synchronise
            4. Synchronisation log
        3. TFS interaction with models and layers
        4. Designing a deployment procedure
        5. Building the solution
        6. Label files
      21. C. Code Editor Scripts
        1. Editor scripts
        2. Code snippet – code commenting
        3. Code snippet – the find method
      22. Index