Saturday, August 13, 2016

Development Tutorial: FormObservable or how to handle display methods in the new Dynamics AX

In the new Dynamics AX the approach to how display/edit methods are refreshed by the kernel has changed to much less aggressive, meaning that after migrating your application to the latest version you might find that after opening the form the data is correct, but after performing actions and editing data the display/edit methods data is not refreshed.

This blog post is going to explain, how to handle such cases now.

I want to stress the importance of reading about this, since this is completely new (among many other things) in AX '7', and without full understanding of these mechanics you will not be able to write efficient and correctly working user interface code.

To summarize, here's a quick set of rules:
  • If your display method depends on form state or some data event, you might need to use one of the following two approaches:
    • The FormObservable attribute to flag an existing form or class variable
    • A new variable of the type FormObservableLink
  • If your display method depends on another data source, you might need to use the following approach:
    • The datasource.observe() method
As you can see from the names of these types, they are relying on the Observer pattern, subscribing to notifications about data changes, so as to invoke the refresh of the display/edit method data.

When I decided to finally write this blog post, I found out there's already somebody who beat me to it, so instead of repeating the same, here's a link, where you can read in more detail about each of the 3 above options:

FormObservable in Dynamics AX7

Enjoy, and kudos to the author of that blog.

Friday, August 12, 2016

Tutorial: Anchoring and Dock management profiles in Warehouse management in Dynamics AX

Scenario introduction

Today I wanted to talk about some of the less known features we have in the Warehouse management module, namely the Anchoring functionality and the Dock management profiles.
Let's start with just describing a scenario where this might be useful.

A company might be reselling goods in an environment, where deliveries are frequent, and there is no time at the dock door to sort out situations where the goods are spread out across multiple staging locations. The trucks need to pick up everything already packed nicely and be off fast. Very often, the truck driver himself would load the goods on the truck, without waiting for warehouse crew (in which case he'd have a WMDP scanner hooked in to our system). Sounds like a typical day for any distributor.

In order to achieve efficiency in the above scenario, multiple things need to come together:
  • In case of multiple picks for the same delivery, they need to all be assembled in the same place so it takes less time then to load them into the truck
  • Since the number of staging / loading lanes is limited, we need to restrict how many deliveries are placed in each one, so there is no confusion later about what goes where
  • Dock scheduling needs to be in place, so there are no hold ups due to unavailability of dock doors upon truck arrival (outside the scope of this blog post)
To help with the 2 first items, you can use anchoring and dock management. Below I will explain how to set it up and walk through a simple example of using these 2 features.


This feature gives you the ability to "anchor" multiple work order lines together, so that items picked all follow the same path in the warehouse. You can choose if you want the work to be grouped together based on the shipment they belong to, or the load they are on.

The setup is very simple, and you only need to choose if you want to anchor by shipment or by load.
It is done on the Mobile device menu items form for any menu items that are of type "Existing work" (apart from Cycle count grouping and Handle by License plate). First you tick the Anchor checkbox, and that will allow you to select what to Anchor by, as shown in the screenshot below:

Anchoring setup on Mobile Device Menu Items
Anchoring on Sales Picking mobile device menu item

And that's it. Now, when any of the work lines from the shipment/load is put down into a specific location, whether that is for staging or at the final shipping location, all other related work lines will be updated with the same location.

All the proper validation, such as checking for mixing rules, batch mixing, status mixing, etc. are performed, of course, along with the check for dock management rules, which we'll talk about below.

This feature is also useful when a worker is to put items for order 1 in a staging location by Dock 1, but can’t because a previous load hasn’t cleared the location. Rather than waiting for the Dock 1 staging location to become available, the worker decides to use the staging location for Dock 2 instead, and overrides the suggested staging location. The put location for all remaining items for the related work orders is updated to the Dock 2 staging location automatically.


If you subsequently override the location when executing one of the anchored puts, that will be allowed, and will not update the other locations, treating this put as a 'special case'. If you do not want that to happen, you could consider not allowing your workers to override Put location (That is set up on the Worker).

Technical details

  • Work is anchored inside the WHSWorkExecuteDisplay.processWork() method, that is, during work execution, more specifically, when executing the Put step.
  • This is done by invoking WHSWorkExecute.anchorWork(), which in turn invokes depending on the setup one of the two methods:
    • WHSWorkTable::anchorWorkByShipment()
    • WHSWorkTable::anchorWorkByLoad()
  • Work lines that were anchored are stamped accordingly through the IsAnchored field

Dock management profiles

This feature extends the restrictions you can put in place on where goods can be placed in the warehouse, e.g., not allowing to have more than 1 item or batch, or inventory status, in a location.
Through dock management profiles you can restrict that items are not placed into a location, if they belong to a different order, or a different load, or even a different work order type. You configure this through the Dock management profiles form, as shown below:

Dock management profiles
Dock management profiles

These rules are validated both when work is only being created (as in, when evaluating the locations found through the Location directives), as well as when executing the Put, as in the above example with anchoring. It is also triggerred when changing the work location for a shipment or load (By clicking on Change work location button in the corresponding form).

Note, that no validation will be performed (including the general mixing rules and stocking limits) when determining the location to Put, if the Assume empty location for new wave is set on the dock management profile.

As the name implies, these restrictions only apply to staging locations and final shipping locations.
You configure this by specifying a dock managment profile on the selected location profile, as shown in the screenshot below:

Location profiles
Dock management profile Id on STAGE location profile

Note, that even though you can specify a dock management profile for any location profile, including inbound, it will not have any effect.

Technical details

  • Class WHSDockManagement is responsible for all the validation ensuring we do not mixed inappropriately in the location. 
    • Static method validateDockMgmtMixing is the entry point

Scenario walk-through


I have highlighted in bold the 3 points I want to make in the walk-through.

I have created the following 3 sales orders for the demo:

  • SO 000779, part of Load USMF-000007
    • 10 pcs of item M9200 from WH 51
    • 20 pcs of item M9201 from WH 51
  • SO 000780, part of Load USMF-000007 (added after the first order was released to warehouse)
    • 7 pcs of item M9200 from WH 51
  • SO 000781, part of Load USMF-000008
    • 3 pcs of item M9201 from WH 51
I have released them to the warehouse, as a result getting three work orders:
  • Work USMF-000017
    • Pick 10 pcs of M9200 from BULK-001
    • Pick 20 pcs of M9201 from BULK-002
    • Put 30 pcs to STAGE
    • Pick 30 pcs from STAGE
    • Put 30 pcs to BAYDOOR
  • Work USMF-000018
    • Pick 7 pcs of M9200 from BULK-001
    • Put 7 pcs of M9200 to STAGE
    • Pick 7 pcs of M9200 from STAGE
    • Put 7 pcs of M9200 to BAYDOOR
  • Work USMF-000019
    • Pick 3 pcs of M9201 from BULK-003
    • Put 3 pcs of M9201 to STAGE2
    • Pick 3 pcs of M9201 from STAGE2
    • Put 3 pcs of M9201 to BAYDOOR
As you can see, the third work was directed to a different staging location, STAGE2, because I have set up the dock management profile to prevent mixing of items not belonging to the same Load. The first two work orders are both going to STAGE, since they belong to the same load.

Now, we will execute the second work and attempt to override the Put location, and put it to STAGE2 instead of the suggested STAGE:

WMDP Put step
Put step for Work USMF-000018

Work exception
Specify reason for Override Location

Location to Put into
Specify new location

Location invalid error
Error message

As you can see, we have received a message "Failed to change location due to dock management rules.". That is as we expected, because we have work 3 already on its way to STAGE2, and it belongs to a different Load, so cannot be mixed.

Let's now specify a valid location, STAGE3, which is empty and has no incoming work:

WMDP Put step with new location
Confirm Put to location STAGE3
After confirming the Put, we get the standard "Work completed" message. Let's now review the work:

Work details
Work USMF-000018
As expected, the second work was updated to reflect the overridden location. This has nothing to do with anchoring, just standard "Override Loc" behavior. But we know that the first work, Work USMF-000017 should also have been updated, because it is anchored by Load. Let's take a look:

Work details
Work USMF-000017
As you can see, it was also updated to now point to STAGE3, both on the Put and the following Pick step (as this is a staging location, so we know there are subsequent steps). Trying to execute this work now would suggest STAGE3 as the location to put the item into. 

The same can happen for loading work, updating the final shipping location on all relevant work lines, if the Sales Loading mobile device menu item was set up accordingly.

Pretty simple, but with great flow control for the warehouse managers out there.


Let me know if you find these features useful, and if you use them in an alternative way in your company / have modifications on top.