Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Microsoft Dynamics AX 2012 Development Cookbook
Microsoft Dynamics AX 2012 Development Cookbook

Microsoft Dynamics AX 2012 Development Cookbook: Customizing Dynamics AX to suit the specific needs of an organization is plain sailing when you use this cookbook of modifications. With more than 80 practical recipes it's the perfect handbook for all Dynamics AX developers.

Arrow left icon
Profile Icon Mindaugas Pocius
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (20 Ratings)
Paperback May 2012 372 pages 1st Edition
eBook
$9.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Mindaugas Pocius
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (20 Ratings)
Paperback May 2012 372 pages 1st Edition
eBook
$9.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$9.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Microsoft Dynamics AX 2012 Development Cookbook

Chapter 2. Working with Forms

In this chapter, we will cover:

  • Creating a dialog

  • Handling a dialog event

  • Building a dynamic form

  • Adding a form splitter

  • Creating a modal form

  • Modifying multiple forms dynamically

  • Storing last form values

  • Using a tree control

  • Building a checklist

  • Adding the View details link

Introduction

Forms in Dynamics AX represent the user interface and are mainly used for entering or modifying data. They are also used for running reports, executing user commands, validating data, and so on.

Normally, forms are created using the AOT by creating a form object and adding form controls such as tabs, tab pages, grids, groups, data fields, images, and others. Form behavior is controlled by its properties or the code in its member methods. The behavior and layout of form controls are also controlled by their properties and the code in their member methods. Although it is very rare, forms can also be created dynamically from the code.

In this chapter, we will cover various aspects of using...

Introduction


Forms in Dynamics AX represent the user interface and are mainly used for entering or modifying data. They are also used for running reports, executing user commands, validating data, and so on.

Normally, forms are created using the AOT by creating a form object and adding form controls such as tabs, tab pages, grids, groups, data fields, images, and others. Form behavior is controlled by its properties or the code in its member methods. The behavior and layout of form controls are also controlled by their properties and the code in their member methods. Although it is very rare, forms can also be created dynamically from the code.

In this chapter, we will cover various aspects of using Dynamics AX forms. We start with building Dynamics AX dialog, and explaining how to handle its events. The chapter will also show how to build a dynamic form, how to add a dynamic control to existing forms, and how to make a modal form.

This chapter also discusses the usage of a splitter and...

Creating a dialog


Dialogs are a way to present users with a simple input form. They are commonly used for small user tasks, such as filling in report values, running batch jobs, presenting only the most important fields to the user when creating a new record, and so on. Dialogs are normally created from X++ code without storing actual layout in the AOT.

The application class Dialog is used to build dialogs. Other application classes, such as DialogField, DialogGroup, DialogTabPage, and others, are used to create dialog controls. A common way of using dialogs is within the RunBase framework classes, where user input is required.

In this example, we will demonstrate how to build a dialog from the code using the RunBase framework class. The dialog will contain customer table fields shown in different groups and tabs for creating a new record. There will be two tab pages, General and Details. The first page will have Customer account and Name input controls. The second page will be divided...

Handling a dialog event


Sometimes in the user interface, it is required to change the status of one field, depending on the status of another field. For example, if the user marks the Show filter checkbox, then another field, Filter, appears or becomes enabled. In AOT forms, this can be done by using the input control modified() event. However, if this feature is required on runtime dialogs, handling events are not that straightforward.

Very often, existing dialogs have to be modified to support eventing. The easiest way of doing that is of course to convert a dialog into an AOT form. However, in cases when the existing dialog is complex enough, probably a more cost effective solution would be to implement dialog event handling instead of converting it into an AOT form. Event handling in dialogs is not as flexible as in AOT forms, but in most cases it does the job.

In this recipe, we will create a dialog very similar to the previous one, but instead of entering the customer number, we will...

Building a dynamic form


A standard approach for creating forms in Dynamics AX is to create and store form objects in the AOT. Using this approach, it is possible to achieve a high level of complexity. However, in a number of cases, it is required to have forms created dynamically. In the standard Dynamics AX application we can see that application objects, such as the Table browser form, various lookups, or dialogs, are built dynamically.

In this recipe, we will create a dynamic form. In order to show how flexible it can be, we will replicate the layout of the existing Customer groups form located in the Accounts receivable module. It can be opened from Accounts receivable | Setup | Customers.

How to do it...

Carry out the following steps in order to complete this recipe:

  1. 1. In the AOT, create a new class called CustGroupDynamic with the following code:

    class CustGroupDynamic
    {
    }
    public static void main(Args _args)
    {
    DictTable dictTable;
    Form form;
    FormBuildDesign design;
    FormBuildDataSource...

Adding a form splitter


In Dynamics AX, more complex forms consist of one or more sections. Each section may contain grids, groups or any other element. In order to maintain section sizes while resizing the form, the sections are normally separated by so-called splitters. Splitters are not special Dynamics AX controls; they are group controls with the properties modified so they look like splitters. Most of the multisection forms in Dynamics AX already contain splitters.

In this recipe, to demonstrate the usage of splitters, we will modify one of the existing forms that does not have a splitter. We will modify the Account reconciliation form in the Cash and bank management module, which can be opened from Cash and bank management | Bank accounts list page, by clicking on the Reconcile | Account reconciliation button in the action pane, and then selecting any of the existing records and hitting the Transactions button. In the following screenshot, you can see that it is not possible to control...

Creating a modal form


Quite often people who are not familiar with computers and software tend to get lost among open application windows. The same could be applied to Dynamics AX. Often a user opens one form, clicks a button to open another one, and then goes back to the first one without closing the second one. Sometimes this happens intentionally, sometimes not, but the result is that the second form is hidden behind the first one and the user starts wondering why it is not possible to close or edit the first form.

Such issues can be easily solved by making the child form a modal window. In other words, the second form always stays on top of the first one until closed. In this recipe, we will do exactly that. As an example, we will make the Create sales order form a modal window.

How to do it...

Carry out the following steps in order to complete this recipe:

  1. 1. Open the SalesCreateOrder form in the AOT, and set its Design property:

    Property

    Value

    WindowType

    Popup

  2. 2. In order to...

Modifying multiple forms dynamically


In the standard Dynamics AX application, there is a class called SysSetupFormRun. Every runtime form inherits that class; therefore the class could be used to override some of the common behavior for all Dynamics AX forms.

For example, form background color could be changed depending on some parameters, some controls could be hidden or added depending on specific circumstances, and so on.

In this recipe, we will modify the SysSetupFormRun class to automatically add an About Microsoft Dynamics AX button to every form in Dynamics AX.

How to do it...

Carry out the following steps in order to complete this recipe:

  1. 1. In the AOT, open SysSetupFormRun class, and create a new method with the following code:

    private void addAboutButton()
    {
    FormActionPaneControl actionPane;
    FormActionPaneTabControl actionPaneTab;
    FormCommandButtonControl cmdAbout;
    FormButtonGroupControl btngrp;
    #define.taskAbout(259)
    actionPane = this.design().controlNum(1);
    if (!actionPane ||
    !(actionPane...

Storing last form values


Dynamics AX has a very useful feature that allows saving of the latest user choices per user per form, report or any other object. This feature is implemented across a number of standard forms, reports, periodic jobs, and other objects, which requires a user input. When developing a new functionality for Dynamics AX, it is recommended to keep it that way.

In this recipe, we will demonstrate how to save the latest user selections. In order to make it as simple as possible, we will use existing filters on the General journal form, which can be opened from General ledger | Journals | General journal. This form contains two filters—Show and Show user-created only. The Show filter allows journals to be displayed by their posting status and the Show user-created only toggles between all journals and the currently logged in user's journals.

How to do it...

Carry out the following steps in order to complete this recipe:

  1. 1. In the AOT, find the LedgerJournalTable form, and...

Using a tree control


Frequent users should notice that some of the Dynamics AX forms use tree controls instead of commonly used grids. In some cases, it is extremely useful, especially when there are parent-child relationships among records. It is a much clearer way to show the whole hierarchy compared to a flat list. For example, projects and their subprojects are displayed in the Projects form of the Project management and accounting module and give a much better overview when displayed in a tree layout.

This recipe will discuss the principles of how to build tree-based forms. As an example, we will use the Budget model form, which can be found in Budgeting | Setup | Budget models. This form contains a list of budget models and their submodels, and although the data is organized using a parent-child structure it is still displayed as a grid. In this recipe, to demonstrate the usage of tree controls, we will replace the grid with a new tree control.

How to do it...

Carry out the following...

Building a checklist


Anyone who has performed a Dynamics AX application installation or upgrade has to be familiar with standard checklists. Normally, a checklist is a list of menu items displayed in a logical sequence. Each item represents either mandatory or optional action to be executed by the user in order to complete the whole procedure. In custom Dynamics AX implementations, checklists can be used as a convenient way to configure non-standard settings. Checklists can also be implemented as a part of third-party modules for their initial setup.

In this recipe, we will create a checklist for user-friendly ledger budget setup. The checklist will consist of two mandatory items and one optional item.

How to do it...

Carry out the following steps in order to complete this recipe:

  1. 1. Open the AOT, and create a new interface named SysCheckListInterfaceBudget:

    interface SysCheckListInterfaceBudget
    extends SysCheckListInterface
    {
    }
    
  2. 2. Create three classes, one for each checklist item, with the...

Adding the View details link


Dynamics AX has a very useful feature, which allows the user to open the main record form with just a few mouse clicks on the current form. The feature is called View details and is available in the right-click context menu on some controls. It is based on table relationships and is available for those controls whose data fields have foreign key relationships with other tables.

Because of the data structure integrity, the View details feature works most of the time. However, when it comes to complex table relations, it does not work correctly or does not work at all. Another example of when this feature does not work automatically is when display or edit methods are used on a form. In those and many other cases, the View details feature has to be implemented manually.

In this recipe, to demonstrate how it works, we will modify the General journal form in the General ledger module and will add the View details feature to the Description control, allowing users...

Left arrow icon Right arrow icon

Key benefits

  • Develop powerful, successful Dynamics AX projects with efficient X++ code with this book and eBook
  • Proven recipes that can be reused in numerous successful Dynamics AX projects
  • Covers general ledger, accounts payable, accounts receivable, project modules and general functionality of Dynamics AX
  • Step-by-step instructions and useful screenshots for easy learning
  • Numerous development tips and tricks for daily usage
  • This book is an update to Microsoft Dynamics AX 2009 Development Cookbook

Description

Microsoft Dynamics AX is a comprehensive Enterprise Resource Planning (ERP) solution for mid-size and large organizations. Dynamics AX implementations are used worldwide by thousands of customers. With the new version - Dynamics AX 2012 - the system is due to expand even more rapidly. Every new implementation requires some level of customization, and all organizations want this to be done to the highest standards using proven approaches. Written by one of the leading experts in Microsoft Dynamics AX, 'Microsoft Dynamics AX 2012 Development Cookbook' is packed with over 80 task-based and immediately reusable recipes that will help you manage your company's or customer's ERP information and operations efficiently, and solve your business process problems in an effective and quick way. This book focuses on commonly used custom modifications in major Dynamics AX modules. The recipes in this book cover various areas of Dynamics AX to help developers not only learn about programming, but also about the functional side of Dynamics AX. The practical recipes will also allow you to look at the development from the perspective of business processes. You will learn to enhance your user interface using various Dynamics AX UI elements and managing your data and functions will become easier.

Who is this book for?

If you are a Dynamics AX developer who is primarily focused on delivering time-proven application modifications, then this book is for you. Although new X++ developers will find this book useful, this book is focused more towards developers who already know the basics of Dynamics AX programming and want to step up to the next level and at the same time learn the functional aspects of Dynamics AX. Some Dynamics AX coding experience is expected.

What you will learn

  • Explore data manipulation concepts in Dynamics AX
  • Build scripts to assist data migration processes
  • Organize data in Dynamics AX forms
  • Enhance your application by using advanced form controls
  • Create custom lookups using AOT forms and dynamically generate them from the X++ code
  • Create and post Dynamics AX journals from code
  • Create and manage purchase and sales orders from code
  • Create a custom electronic payment format and process a vendor payment using it
  • Integrate your application with Microsoft Office Suite
  • Create various Microsoft Office documents that can be used for exporting/importing business data for further distribution or analysis
  • Integrate the system with external systems using various approaches
  • Improve your development efficiency and experience
  • Learn simple but effective tips on how to improve overall Dynamics AX performance

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 04, 2012
Length: 372 pages
Edition : 1st
Language : English
ISBN-13 : 9781849684644
Vendor :
Microsoft
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : May 04, 2012
Length: 372 pages
Edition : 1st
Language : English
ISBN-13 : 9781849684644
Vendor :
Microsoft
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $29.97 $95.97 $66.00 saved
Microsoft Dynamics AX 2012 Services
$43.99
Microsoft Dynamics AX 2012 Development Cookbook
$54.99
Extending Microsoft Dynamics AX 2012 Cookbook
$60.99
Total $29.97$95.97 $66.00 saved Stars icon
Banner background image

Table of Contents

9 Chapters
Processing Data Chevron down icon Chevron up icon
Working with Forms Chevron down icon Chevron up icon
Working with Data in Forms Chevron down icon Chevron up icon
Building Lookups Chevron down icon Chevron up icon
Processing Business Tasks Chevron down icon Chevron up icon
Integration with Microsoft Office Chevron down icon Chevron up icon
Using Services Chevron down icon Chevron up icon
Improving Development Efficiency Chevron down icon Chevron up icon
Improving Dynamics AX Performance Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(20 Ratings)
5 star 40%
4 star 45%
3 star 10%
2 star 5%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Bojan Jovicic Jul 18, 2012
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book contains a wealth of information about most of the key areas used while developing new or modifying existing functionalities in Microsoft Dynamics AX 2012. A warm recommendation for every Microsoft Dynamics AX 2012 developer.
Amazon Verified review Amazon
SA Jun 27, 2012
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is addressing the typical AX development tasks with easy steps to follow. I think it should be close to, at least, every technical person,... you don't know when it comes handy?
Amazon Verified review Amazon
Amazon customer Jul 15, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As Dynamics AX developers, we are working with a niche product and do not have an abundance of technical literature as more generic development technologies enjoy. One can find a lot of answers by googling but having an academic approach to learning I cannot overestimate the amount of knowledge one can pick up from reading a good book.The “Microsoft Dynamics AX 2012 R3 Cookbook” provides an excellent set of real-life scenarios and solutions that can be applied as is or help to come up with creative ways of approaching development tasks we face. The recipes apply to many areas of AX, are very well explained and come with well-written code samples.I highly recommend this book to those starting their Dynamics AX development career as well as mature developers who will still find new tricks or refresh their memory.
Amazon Verified review Amazon
Kambiz Jun 17, 2012
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Major changes in contrast with ax 2009 cook book, usefull topics, powerfull edition in order to follow the processes, merge technical with required functional point of view to complete the tasks...
Amazon Verified review Amazon
Hal 9000 Aug 18, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Not for the beginner, more focused on X++, class constructs and work around with suggestions, tips and tricks
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.