Dissecting the Warehouse Management app layout

Dissecting the Warehouse Management app layout

The layout of the Dynamics 365 Warehouse Management app is managed by both the App code and the D365 SCM core to ensure a productive workflow. The app receives a state from the Dynamics 365 SCM core encapsulated in a “container,” comprising a list of controls to be presented on the current screen. These hints include the DisplayArea  assignment (the display area where controls that are awaiting input or confirmation are found, see Inspect details of active Warehouse Management mobile app sessions – Supply Chain Management | Dynamics 365 | Microsoft Learn) and the InstructionControl reference for item ID, quantity, location confirmations.

Typically, controls without default values are positioned in the Primary Input Area, awaiting user input through scanning or manual entry. In the above example, the next empty control is LP (license plate) i.e. the licence plate to pick the goods from. These controls which require a user input are presented one after another following the order of controls in the “container” or the explicit Display Priority, if provided by the programmer of the warehouse menu item UI. This is perceived by the user as a series of screens; internally, it remains the same screen.

To determine the DisplayArea, the D365 core employs heuristics. Controls with default values slide down to the Info and Secondary Input Area, except for confirmation fields like Confirm Location, which appear in the Primary Input Area despite seemingly having a default value. The initial value is still empty, but the InstructionControl let the warehouse app present a hint from a different field and display it in italic (here: BULK-010).

Upon assigning values to all controls, the screen is considered complete, triggering the button in the Primary Action Area.

Control placement on the Warehouse Management app screen can be influenced through the WHSMobileAppServiceDecoratorRule class family. For instance, a control with a non-empty default value can still be prompted in the primary input area, as demonstrated in the below code snippet:

[SubscribesTo(classStr(WHSMobileAppServiceDecoratorRuleDefaultDisplayArea), staticDelegateStr(WHSMobileAppServiceDecoratorRuleDefaultDisplayArea, isTextInPrimaryInputAreaDelegate))]
public static void WHSMobileAppServiceDecorator_isTextInPrimaryInputAreaDelegate(boolean _enabled, Map _controlMap, str _data, WHSMenuItemName _menuItemName, EventHandlerResult _result)
   if (_enabled && _controlMap.lookup(#XMLControlName) == #MyControl)

It is important to remove (to be exact, not to rebuild after the last user interaction) such a control from the screen once it receives its input, otherwise it will be prompted repeatedly in an infinite loop.

The second example showcases a custom control with an InstructionControl reference for requesting confirmations while presenting a hint in italic:

final class WHSMobileAppServiceDecoratorRuleInstruction_Extension
   protected WHSMobileAppControlName getInstructionControlName(WHSMobileAppControlName _controlName)
      WHSMobileAppControlName confirmationControl = _controlName;
      WHSMobileAppControlName masterControl;
      masterControl = next getInstructionControlName(confirmationControl);
      if (confirmationControl == #MyControl)
         masterControl = #MyMasterControl;
      return masterControl;

How NOT to send an order confirmation per e-mail

How NOT to send an order confirmation per e-mail

When utilizing configurable business documents (Electronic Reporting) in Dynamics 365, additional steps are required to dispatch various documents such as invoices, delivery notes (referred to as packing slips in the US), sales order confirmations to customers, or purchase order requests to suppliers. Begin as usual with Accounts receivable > Setup > Forms > Form setup, Print management. Select the appropriate Electronic Reporting (ER) configuration as a Report format.

It’s important to note that the conventional flexible print destinations outlined in Set up print management for a module | Microsoft Learn are not applicable for ER reports. Instead, navigate to Organisation Administration > Electronic Reporting > Electronic reporting destination. Here, for each ER configurable business document, create a dedicated line where you can specify Email as the destination under the Settings.

Programmable e-mail recipients

Here’s where it gets interesting: for each From, To, Cc address, clicking Edit provides you with the flexibility to choose between the traditional hard-coded method of extracting business party account details (+Add, Print Management email) or the Configuration email, featuring a low-code ER formula. When opting for the latter choice, Electronic Reporting grants access to the corresponding ER model.

The From formula can be a simple hardcoded text with the unattended e-mail address: "noreply@erconsult.eu".  The mails will be sent via SMTP on its behalf, thus it must be a true Exchange 365 account.

The To = @Business@ field is employed to choose one among several electronic contact addresses (emails) of the party based on the electronic address Purpose. This configuration remains consistent with the classic Print Management setup.

For the Email source account for the To e-mail address, consider the following examples:

Configurable Business Document Party ER Formula to extract the account number
Sales order confirmation Customer model.SalesConfirm.BuyerCustomerParty.Party.PartyIdentification.AccountNumber
Sales order packing slip Customer Missing in the mapping; modify model.BuyerCustomerParty
Sales invoice Customer model.InvoiceBase.InvoiceAccount.AccountNum
Free text invoice Customer model.Customer.AccountNum
Collection letter note Customer model.AccountingCustomerParty.AccountNum
Purchase order Supplier model.PurchaseOrderInquiry.SellerSupplierParty.Party.Reference

The subject of the email can either be set as a fixed value, such as “Lieferschein / Delivery note” or dynamically constructed from components of the document model. This dynamic approach is particularly useful for the Body of the email. The FORMAT function with placeholders does not work. Instead, HTML tags must be concatenated sequentially. Thank you Ludwig Reinhard for this hint. Here is a sample:

"Dear Ladies and Gentlemen,"&"<br>"&"Attached you may find invoice "&model.InvoiceBase.Id&” for your order"&model.InvoiceBase.SalesId&".”&"<br>"&"Best regards, XXX"

Reprint documents safely

In the described setup, Dynamics 365 will automatically dispatch your configurable business documents to your business partners via email every time, even if you attempt to reprint or review the invoice, order confirmation, etc. The customers and suppliers will go nuts. Fortunately, a solution has been introduced since 2021: a feature known as Configure action-dependent ER destinations – Finance & Operations | Dynamics 365 | Microsoft Learn. This feature responds to the button clicked by the user—whether it’s ‘Copy,’ ‘Original,’ or ‘Use Print Management‘—and redirects the document to a different destination, providing a more controlled document distribution process.

With the configuration shown below, reprinted copies of an invoice are directed exclusively to the screen. The ‘View‘ option corresponds here to the buttons Copy preview and Original preview. The ‘Print‘ action is initiated during every post-and-print action when the configurable document is initially generated. Additionally, the ‘Print‘ action is triggered when the user deliberately selects Use print management for reprinting.

Do not send pro-forma documents to your business partners

The electronic reporting destinations unfold their devious nature when the people first preview a document before sending. Dynamics 365 is going to send the document via email regardless of whether the user opts to Use print management or not, proforma or not a proforma.  Namely, both generating a pro-forma sales order confirmation and posting a final sales order confirmation are considered Print actions. This aspect bears potential legal consequences.

The recent feature, “Allow ER destinations adjustment at runtime (Phase 2)“, introduced in version 10.0.36, may offer assistance. However, I consider it intrusive and unsafe as it opens an additional dialog window placing the decision-making in the hands of the user: humans make mistakes.

We’ve identified a somewhat unconventional but more straightforward solution by manipulating and corrupting the Email source account mentioned earlier. Consider the following example:

IF(LEN(model.InvoiceBase.Id)>0, model.InvoiceBase.InvoiceAccount.AccountNum, "FUBAR")

If the invoice number is empty, the system returns a fabricated account number; otherwise, it returns the legitimate account number.

When attempting to send a copy of a pro-forma invoice to the customer’s email address, an exception will be raised, stating, “The email address in the To field is not valid.” The Screen destination will still succeed despite this exception.