Cart 0

Gamifying Your Customers By Creating Fact Boxes To Show Achievement Badges

Posted by Murray Fife on

You can see them all of Dynamics AX. Fact boxes are a great way to show information relating to the current record that you are in, without cluttering up the main data in the form. Also you can pick and choose if you want to see the information as well. But you don’t have to settle for the fact boxes that are delivered with Dynamics AX, you can easily create some more of your own if you don’t mind getting your hands a little dirty with a little coding.

What a great way to Gamify your customers.

How To Do It…

Setting Up Your Fact Box Development Project

The first thing that you will want to do is to create a development for your fact box project so that you can keep all of your development packaged up in a nice little box.

  1. Start off by finding the form that you want to add the fact box to. In this example, the Customers form will be a great place to start.
  2. Then right-mouse-click on the main form and select the Personalize option from the context menu bar.
  3. When the Personalization dialog box is displayed, switch to the Information tab and you will see the actual Form Name. Click on the Edit button to the right pof the Form Name field.
  4. This will open up the AOT development environment with the form definition already selected.
  5. In the menu bar, click on the Projects button to open up the Projects Explorer window.
  6. Right-mouse-click on the Private projects folder and select the New menu item and then the Project option.
  7. This will create a new Project for you.
  8. Double-click on the Project name and you will be able to rename it to something that is a little more descriptive.
  9. Now tile the two windows so that you can see both the form and the project window.
  10. Grab the CustTable form and drag it over to the Project to add it to your project package.
  11. Now you can close down the form window and start focusing on the project itself.

Creating The Fact Box Form

Now that we have our project set up we can start working on building the fact box. The first thing that we need to do is create a form that we will use to display our button in.

  1. To do this, right-mouse-click on the project folder and then from the New submenu select the Form menu item.
  2. This will create a new form for you.
  3. Double-click on the form so that you can rename it to something that is a little more suited to the project.
  4. The trick with the Fact boxes is that they need to have a data source associated with them that is linked back to the parent form so that we can use it to craft the data for the badges. To do this, click on the DataSources folder within the form and select the New DataSource option.
  5. When the new DataSource is created, select it and then within the Properties panel you will be able to give your Then from the Table dropdown select the table that you want to use as a link. In this case we want the CustTable.
  6. Then change the OnlyFetchActive property to be Yes. This will tell the form to grab the currently active record from the parent table.

Creating The Fact Box Form Part

Now that we have the Form that we will use for the Fact Box we need to wrap it within a Form Part so that Dynamics AX will allow us to use it as a Fact Box.

  1. To do this, right-mouse-click on the projects top level and select the New submenu, and then select the Parts submenu
    so that you can select the Form Part menu item.
  2. This will create a new FormPart for you.
  3. Double-click on the FormPart so that you can rename it to a friendlier name and also update the Caption property.
  4. From the Form property click on the dropdown list and select the form that you just created.
  5. After you have done that you can continue to the next step.

Creating The Fact Box Menu Item

Once we have a FormPart, we need to create a menu item that points to it so that we can add it to our main form.

  1. To do this, right-mouse-click on the projects top level and select the New submenu, and then select the Menu Item submenu and then select the Display menu item.
  2. This will create a new menu item for you.
  3. Within the Properties of the menu item, set the Name and Label fields to something a little friendlier.
  4. Then change the ObjectType to FormPart.
  5. That will allow you to select your new FormPart that you just created from the Object property dropdown list.
  6. After you have selected the FormPart you are done with this step.

Adding The Form Part To The Main Form

Now we can add fact box to our main form.

  1. To do this, expand out the main form, and then expand out the Parts folder. You will see all of the fact boxes that have already been added to the form.
  2. Right-mouse-click on the Parts node and select the New Part Reference menu item.
  3. This will add a new Part to your form.
  4. Within the Properties for the Part, change the Name property to a better name.
  5. Then select the new Menu Item that you created from the MenuItemName dropdown list,
  6. The DataSource should automatically default in as the main table (in this case the CustTable) so you just need to select the SelfLink option from the DataSourceRelation dropdown to tell it to link with the form datasource.
  7. All done.

Viewing The Fact Box

Now we have created enough to see part of the project in action.

  1. When you re-open up the CustTable form you should see a new Fact Box is shown.

How cool is that!

Adding The Customer Achievement Charms

Now that we have the Fact Box we can start populating it with some cool charms and badges.

  1. To do this expand out the Fact Box Form that you initially created, expand out the Designs group and right-mouse-click on the Design node. Select the New Control menu item and select the Button menu item.
  2. This will create a new Button for you which is a great way to show images.
  3. Change the Name property on the button to a name that is easier to reference.
  4. Then change the ButtonDisplay property to Image Only so that it will show just a picture.
  5. Now click on the button to the right of the NormalImage property and select the image that you want to show when the badge is turned on.
  6. This will add the path to the image into the property field.
  7. Now click on the button to the right of the DisabledImage property field and select the disabled image.
  8. You may also want to set the Enabled property to be No by default.
  9. To make the button look less like a button, change the Border property to None.
  10. And also set the BackStyle property to Transparent.
  11. Now you can save your project by clicking on the Save icon in the tool bar.
  12. If you take a peek at the Customer form you will now see that the image is shown.

Adding Logic To Manage The Badge

There is only one step left to go, and that is to add a little logic to the fact box so that it starts updating based on the data that is in the main form.

  1. To do this we need to write some code that is triggered off the data changing. An easy place to do this is the CustTable datasource, so expand out the Fact Box Form, expand the DataSources, and then the CustTable datasource that you originally added.
  2. Right-mouse-click on the Methods node and select the Override Method option and then select the Active method.
  3. This will open up the X++ code editor for you with the default methods code.
  4. Then add the following code to the method


    SalesTable salesTable;


    count(RecId) From salesTable

    where salesTable.CustAccount == CustTable.AccountNum;

    recCount = salesTable.RecId;“TopCustomerBadge”).enabled(recCount > 1);

  5. You can now close the editor and save the project.
  6. Now when you browse to the customers, if they don’t have any sales orders then the badge is disabled.
  7. When you do find a customer that has some sales associated with it then it starts to light up.


If information is power, then Fact Boxes are the currency when it comes to Dynamics AX. There are so many examples that we can think of where an additional Fact Box would be useful to display another snippet of information that you may need to do your job just a little quicker. By using Fact Boxes, the users can also pick and choose what information they see without cluttering up the main forms or adding too much extra noise to the application.

Although they do involve a little bit of code, they are really not hard to create so what are you waiting for?

To view the original post and also to download the step by step instructions with screen shots, visit the Dynamics AX Companions Website:

Share this post

← Older Post Newer Post →

Leave a comment

Please note, comments must be approved before they are published.