Book Image

Mastering Microsoft Dynamics AX 2012 R3 Programming

By : Simon Buxton, Mat Fergusson
Book Image

Mastering Microsoft Dynamics AX 2012 R3 Programming

By: Simon Buxton, Mat Fergusson

Overview of this book

<p>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.</p> <p>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.</p>
Table of Contents (21 chapters)
Mastering Microsoft Dynamics AX 2012 R3 Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Microsoft Dynamics AX is an ERP solution for complex single site and multi-site, multilanguage global enterprises. This flexible and agile solution provides both advanced built-in functionality and an industry leading integrated development environment, allowing an organization to provide even higher levels of fit. This book should be in the tool belt of any software engineer who works with Dynamics AX.

This book aims at providing software engineers and those involved in developing solutions within Dynamics AX with clear guidance of best practices, and theory and practical examples covering broad areas of the Dynamics AX integrated development environment and surrounding technologies. Even for experienced software engineers, this book will provide a good source of reference for efficient software development. The book's easy-to-follow practical guidance will help your solutions to be easier to maintain, extend, and upgrade.

In order to facilitate this, the book follows the development of a solution as a means to explain the design and development of data structures, classes, forms, BI, menu structures, and security. Concepts such as models, layers, software development patterns, and frameworks are explained and have been given a real-world context and perspective using the authors' experiences to point out the many traps that lay in wait, demonstrating not only how to write flexible solutions, but also why a design approach has been taken.

The structure of the book was designed so that it is useful in a practical sense from the initial chapters, without sacrificing the required theory that is needed to provide the necessary depth of knowledge when working with Dynamics AX. By Chapter 3, Creating the User Interface, we have a working solution for maintaining data, and by the end of Chapter 7, Designing Your Security Model, we cover most of what is required from many solutions. The earlier chapters provide a fast-paced tutorial for new developers to AX and a refresher for those already developing in AX using the latest best practices and software development patterns. The later chapters cover advanced development techniques and features that will help even the experienced Dynamics AX software engineers.

The sample solution was designed and developed as the book was written, and is available for download. It was co-developed by two authors living in different countries using Team Foundation Server with Visual Studio Online.

With this comprehensive tutorial, you will be armed with the knowledge and insight you need to develop well design solutions that will help your organization to get the most value from this comprehensive solution for both this and upcoming releases of Microsoft Dynamics AX.

What this book covers

Chapter 1, Preparing Our Solution, provides both the theory and practical steps that are followed when starting work on a new solution. This includes minimizing code footprint; creating a model, project, and label file; configuring source control; and designing the technical solution and test plans.

Chapter 2, Creating Data Structures, guides us through the creation of the data structures used for our hypothetical solution, bringing in new concepts such as table inheritance, extended data types, enumerated types, and referential integrity.

Chapter 3, Creating the User Interface, includes the creation of the user interface using standard design patterns for development of the forms and menu structure. We also demonstrate how to make form logic reusable by moving code to a class.

Chapter 4, Creating Business Logic and Hooking into Core AX, covers how to handle table events in a class for easier reusability by adding navigation and using number sequences. It also includes how to hook into core AX using eventing and delegates to minimize the footprint on standard code.

Chapter 5, Adding Business Intelligence, provides practical hands-on guidance for the creation of parts in order to provide real-time, pervasive business intelligence to our users through Info parts, Form parts, Cues, and Cue groups. Also covered is the interaction between form parts and the host form and how to control queries programmatically.

Chapter 6, Extending the Solution, lets you dive deeper into the solution we have developed by adding secondary list pages, drop dialogs, and reusable business logic with data contracts and exposing business logic to external applications through services.

Chapter 7, Designing Your Security Model, covers the design and development of the security of our solution, including roles, duties, privileges, and process cycles. We also cover code access permissions and how to secure data through the use of data policies (extensible data security).

Chapter 8, Customizing Standard AX, provides guidance on how (and where) to modify standard or third-party code without suffering the maintenance cost associated with upgrading the modified code. Also included is using standard frameworks, demonstrated by example of vendor electronic payments.

Chapter 9, Advanced Features and Frameworks, demystifies the more advanced topics such as the SysOperation framework, global address book, and the financial dimension framework through clear practical examples of how these should be used.

Chapter 10, Advanced Development Techniques, covers date effective tables, exception handling, computed columns on views, and controlling the tier our code runs on. We also step into the world of using metadata, making sense of advanced techniques many may shy away from.

Chapter 11, Unit and Performance Testing, covers practical guidance on unit and performance testing, including how to create automated test plans that help us avoid the regression that changes often incur. Performance testing and diagnosis is explained through the use of the code profiler, which covers analysis on both the code and database performance.

Appendix A, Efficient Design and Development with Microsoft Dynamics AX, covers the technical overview of Dynamics AX, models, layers, and the integrated development environment.

Appendix B, Using Version Control, provides guidance on how to use version control covering the interaction between version control and models and layers, how to build your solution, and how version control works with label files.

Appendix C, Code Editor Scripts, provides information and code samples on how to extend the standard code editor scripts, saving your time while developing code.

What you need for this book

The easiest way to follow the code samples in this book is to use one of the Microsoft Dynamics 2012 R3 solution demonstration VMs available from Partnersource or Customersource. You should use the latest available; this book was written to use CU8, with the differences to CU7 (or prior) explained.

Who this book is for

If you are a software developer, who has started developing in Dynamics AX 2012 or an experienced software engineer migrating from an earlier version of Dynamics AX, this book is an ideal tutorial to help you make the most of this advanced technology. This book is also useful if you are a technical solution architect or technical consultant as it provides a deeper insight into the technology behind the solution.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "In our example, we will use 6015GettingStarted as the project name."

A block of code is set as follows:

public Common resolveReference(FormReferenceControl
                                           _formReferenceControl)
{
    Common category;
    EcoResCategoryHierarchy     hierarchy;
    EcoResCategoryHierarchyRole role;

    select firstonly * from hierarchy
        join role
            where hierarchy.RecId == role.CategoryHierarchy
               && role.NamedCategoryHierarchyRole ==
                  EcoResCategoryNamedHierarchyRole::Procurement;

    category = EcoResCategory::resolveCategoryHierarchy(
                               _formReferenceControl, hierarchy);

    return category.RecId ? category : null;
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public Common resolveReference(FormReferenceControl
                                           _formReferenceControl)
{
    Common category;
    EcoResCategoryHierarchy     hierarchy;
    EcoResCategoryHierarchyRole role;

    select firstonly * from hierarchy
        join role
            where hierarchy.RecId == role.CategoryHierarchy
               && role.NamedCategoryHierarchyRole ==
                  EcoResCategoryNamedHierarchyRole::Procurement;

    category = EcoResCategory::resolveCategoryHierarchy(
                               _formReferenceControl, hierarchy);

    return category.RecId ? category : null;
}

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Press OK."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/6015EN_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.