Preface
In Microsoft Dynamics 365 Business Central the extension model is object-based.
You create new objects, and extend existing objects depending on what you want your extension to do. The underlying Mobile WMS source code is now sealed and can no longer be modified directly.
This necessitated a refactoring of our model for making custom changes to the Xml Requests and Xml Responses which are being communicated between the mobile devices and the Mobile WMS backend in Business Central. As a part of this refactoring, we are introducing new "accessor" layer to manipulate the Xml content, but with no need to manipulate the Xml Documents directly as to date.
Past model (C/SIDE)
Changes to XML Response was made directly in handler codeunits, e.g. "MOB WMS Receive" etc.
Changes implied writing directly to the XML output, and required knowledge of the XML element, case sensitive tags and using correct namespaces.
Example:
// The choices are: None, Warn, Block
// MobXMLMgt.AddElement(XMLOrderLine, 'UnderDeliveryValidation', 'Warn', BaseDataModelNS, XMLCreatedNode);
MobXMLMgt.AddElement(XMLOrderLine, 'UnderDeliveryValidation', 'Block', BaseDataModelNS, XMLCreatedNode);
New model (AL)
Changes to XML Responses now requires Event Subscriber procedures to be declared in your own code.
Changes are now strictly in your own project, and the underlying Mobile WMS source code is no longer modified.
You can subscribe to (among others) a number of "On After Set From XXX"-events .
Rather than manipulating the Xml output directly, values are now set in new "accessor table" that hides all underlying Xml considerations. By using Set/Get accessor methods in these accessor tables, content is automatically formatted and inserted at correct nodes and namespaces in the Xml documents.
Example:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAfterSetFromAnyLine', '', true, true)]
procedure OnReceiveOnAfterSetFromAnyLine(_RecRef: RecordRef; var _BaseOrderLineElement: Record "MOB Ns BaseDataModel Buffer")
begin
// Under-/OverDeliveryValidation - The choices are: None, Warn, Block
_BaseOrderLineElement.Set_UnderDeliveryValidation('Block');
end;
"Accessor tables"
A central part of the Extension API is an "accessor layer" to manipulate the XML content, but with no need to manipulate the XML Documents directly.
You are given functions that handles XML behind-the-scenes for you.
Derived from C#
Our "accessor table" -concept is derived from C# property classes.
- Properties combine aspects of both fields and methods.
- To the user of an object, a property appears to be a field, accessing the property requires the same syntax.
- To the implementer of a class, a property is one or two code blocks, representing a Get accessor and/or a Set accessor. The code block for the
get
accessor is executed when the property is read; the code block for theSet-
accessor is executed when the property is assigned a new value. - Properties have many uses: they can validate data before allowing a change; they can transparently expose data on a class where that data is actually retrieved from some other source, such as a database; they can take an action when data is changed, such as raising an event, or changing the value of other fields.
Example, C#
class Person { private string name; // the name field public string Name // the Name property { get { return name; } set { name = value; } } }
Accessor Tables (AL)
Since Codeunits cannot be used as parameters in all BC versions, we have introduced "accesssor tables". Basically C# style acccessor classes, but implemented at table level.
Each table corresponds to a specific part of the Mobile WMS XML schema, and makes available get/set accessors for each node in corresponding namespaces.
Support for your custom fields
Every accessor table includes get/set-methods to add custom elements not being a part of the standard schema, including as CDATA elements.
This enables you to carry custom data to the Mobile Device when you customize Mobile WMS.
List of tables
Ns Resp Element
The simplest accessor table, which only has one get/set-method property: "Description".
- Get_description(): Text
- Set_description(NewValue: Text)
- GetValue(_PathToGet: Text): Text
- SetValue(_PathToSet: Text; _NewValue: Text)
SetValueAsCData(_PathToSet: Text; _NewXmlCData: XmlCData)
SetValueAsCData(_PathToSet: Text; _NewCDataValue: Text)
Ns BaseDataModel Element
The "MOB Ns BaseDataModel Element" is used to build "<BaseOrder>" and "<BaseOrderLine>" elements in the BaseDataModel namespace. It is the most frequently used new accessor table by far. All 'GetXXXOrdes" and "GetXXXOrderLines" requests will make this accessor table available from a number of new "OnAfterSetFrom[...]"-events.
Sample use is i.e. OnGetReceiveOrders_OnAfterSetFromWarehouseReceiptHeader and OnGetCountOrders_OnAfterSetFromItemJournalBatch
At time of writing (August 2019) this accessor table supports these following tags:
- Get / Set_BackendID
- Get / Set_OrderBackendID
- Get / Set_LineNumber (set by Integer or Text)
- Get / Set_FromBin
- Get / Set_ValidateFromBin (set by Boolean or Text)
- Get / Set_ToBin
- Get / Set_ValidateToBin (set by Boolean or Text)
- Get / Set_AllowBinChange (set by Boolean or Text)
- Get / Set_ItemNumber
- Get / Set_ItemBarcode
- Get / Set_Description
- Get / Set_RegisterSerialNumber (set by Boolean or Text)
- Get / Set_RegisterLotNumber (set by Boolean or Text)
- Get / Set_RegisterExpirationDate (set by Date or Text)
- Get / Set_RegisterQtyByScan
- Get / Set_SerialNumber
- Get / Set_LotNumber
- Get / Set_Quantity (set by Decimal or Text)
- Get / Set_RegisteredQuantity
- Get / Set_UnitOfMeasure
- Get / Set_Status
- Get / Set_HeaderLabel1
- Get / Set_HeaderLabel2
- Get / Set_HeaderValue1
- Get / Set_HeaderValue2
- Get / Set_DisplayLine1
- Get / Set_DisplayLine2
- Get / Set_DisplayLine3
- Get / Set_DisplayLine4
- Get / Set_DisplayLine5
- Get / Set_UnderDeliveryValidation
- Get / Set_OverDeliveryValidation
- Get / Set_ItemImageID
... for Tote Picking only: - Get / Set_TotePicking (set by Boolean or Text)
- Get / Set_Destination
- Get / Set_Priority
... for sorting. Is never written Xml Response directly but used by the Mobile WMS base application to determine and populate <Sorting>-tag
... unlike versions prior to MOB5.00, the <Sorting> tag can no longer be set directly but is always populated by the system. - Get / Set_Sorting1 (internal) (set by Integer, Date or Text –> will be formatted and padded as needed to match sql sorting)
- Get / Set_Sorting2 (internal) (- do -)
- Get / Set_Sorting3 (internal) (- do -)
- Get / Set_Sorting4 (internal) (- do -)
- Get / Set_Sorting5 (internal) (- do -)
... for new (custom) tags:
- GetValue(_PathToGet: Text): Text
- SetValue(_PathToSet: Text; _NewValue: Text)
SetValueAsCData(_PathToSet: Text; _NewXmlCData: XmlCData)
SetValueAsCData(_PathToSet: Text; _NewCDataValue: Text)
Ns WhseInquiry Element
The "MOB Ns WhseInquiry Element" is used to build "<LookupResponse>"-elements in the WarehouseInquiryDataModel namespace. It is used from the "MOB WMS Lookup" codeunit.
Sample use is i.e. OnLookupOnLocateItem_OnAfterSetFromBinContent and OnLookupOnPostShipment_OnAfterSetFromWarehouseShipmentHeader
At time of writing (August 2019) this accessor table supports these following tags:
- Get / Set_Location
- Get / Set_ItemNumber
- Get / Set_Barcode
- Get / Set_DisplaySerialNumber (Note: Text field to display SerialNumber including leading label)
- Get / Set_SerialNumber
- Get / Set_DisplayLotNumber (Note: Text field to display LotNumber including leading label)
- Get / Set_LotNumber
- Get / Set_DisplayExpirationDate (Note: Text field to display ExpirationDate including leading label)
- Get / Set_ExpirationDate (set by Date or Text)
- Get / Set_Bin
- Get / Set_Quantity (set by Decimal or Text)
- Get / Set_UoM
- Get / Set_DisplayLine1
- Get / Set_DisplayLine2
- Get / Set_DisplayLine3
- Get / Set_DisplayLine4
- Get / Set_DisplayLine5
- Get / Set_ExtraInfo1
- Get / Set_ExtraInfo2
- Get / Set_ExtraInfo3
... for "LookupPostShipment" only: - Get / Set_ShipmentNo
... for sorting. Is never written Xml Response directly but used by the Mobile WMS base application to determine and populate <Sorting>-tag
... Unlike versions prior to MOB4.50, the <Sorting> tag can no longer be set directly but is always populated by the system.
- Get / Set_Sorting1 (internal) (set by Integer, Date or Text –> will be formatted and padded as needed to match sql sorting)
- Get / Set_Sorting2 (internal) (- do -)
- Get / Set_Sorting3 (internal) (- do -)
- Get / Set_Sorting4 (internal) (- do -)
- Get / Set_Sorting5 (internal) (- do -)
... for new (custom) tags with no preexisting Get/Set-methods:
- GetValue(_PathToGet: Text): Text
- SetValue(_PathToSet: Text; _NewValue: Text)
SetValueAsCData(_PathToSet: Text; _NewXmlCData: XmlCData)
SetValueAsCData(_PathToSet: Text; _NewCDataValue: Text)
Ns Request Element
The "MOB Ns Request Element" is used to read data from "Request"-XmlDocuments.
At time of writing (November 2020) this accessor table supports these following tags that correspends to HeaderFields used by the standard Mobile WMS Application:
- Get_AssignedUser
- Get_Bin
- Get_Date
- Get_ExpirationDate
- Get_FilterLocation
- Get_FromBin
- Get_Item
- Get_ItemCategory
- Get_ItemDescription
- Get_ItemNo
- Get_ItemNumber
- Get_Location
- Get_LocationFilter
- Get_LotNumber
- Get_OrderBackendID
- Get_PurchaseOrderNumber
- Get_Quantity
- Get_ReferenceID
- Get_ShipmentNoFilter
- Get_ToBin
- Get_ToteID
- Get_UnitOfMeasure
- Get_ContextValuesAsWhseInquiryElement - requires Android App 1.5.5 and Mobile WMS 5.22 (or newer)
... for new (custom) tags with no preexisting Get/Set-methods:
- GetValue(_PathToGet: Text): Text
- SetValue(_PathToSet: Text; _NewValue: Text)
- GetContextValue(_PathToGet: Text): Text - requires Android App 1.5.5 and Mobile WMS 5.22 (or newer)
In legacy versions...
- GetValue requires the tag to be in requestData-section of the Xml Request.
- The tag must have a corresponding HeaderField in the HeaderConfiguration declared for the page.
- Only tags with corresponding and exactly equally named HeaderFields is transferred from the calling page ("context") to the Xml Request
Since Android App 1.5.5 additional "ContextValues" is sent with the Xml Request when calling an action from any page.
Reading such "ContextValues" requires Mobile WMS 5.22 (or newer).
- Actions from Lookup-pages provides additonal "ContextValues" with their request
- ContextValues can be read directly using GetContextValue if you need the original value when same tag exists as RequestData, or with GetValueOrContextValue (fallback to ContextValue if RequestData do not exist).
- All values from LookupResponse-elements from "caller" pages is added to the Xml Request and can be accessed with no need for a corresponding HeaderField