...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
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 Resquests and Xml Responses that is 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.
...
// 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 is now set in new "accesssor 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.
...
[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 class (C#)
New "accessor tables" has been introduced to Mobile WMS. The accessor tables 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 the set
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# syntax
Code Block | ||||
---|---|---|---|---|
| ||||
class Person
{
private string name; // the name field
public string Name // the Name property
{
get
{
return name;
}
set
{
name = value;
}
}
} |
Accessor table (AL)
In AL, codeunits (the AL equivalent for C# classes) cannot be parameters to procedures/methods, unlike in C# (newer BC versions indeed supports codeunits as parameters, but this is not the case for every BC version we support). This makes AL codeunits a poor choice when temporary data needs to be stored and transferred between codeunits and procedures. Instead, we have introduced new "accesssor tables" in Mobile WMS, basically being C# style acccessor classes, but implemented at table level.
Three new accessor tables has been introduced. Each table corresponds to a specfic part of the Mobile WMS Xml schema, and makes available get/set accessors for each node in corresponding namespaces.
- table 6181380 "MOB Ns Resp Element"
- table 6181381 "MOB Ns BaseDataModel Element"
- table 6181382 "MOB Ns WhseInquery Element"
"MOB Ns Resp Element" is the most simple of those, and includes only get/set-methods for one predefined property "description". Also, every accessor table includes get/set-methods to add custom elements not being a part of the standard schema, including as CDATA elements:
- Get_description(): Text
- Set_description(NewValue: Text)
...
SetValueAsCData(_PathToSet: Text; _NewXmlCData: XmlCData)
...
Ns BaseDataModel Element (Accessor table, AL)
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:
...
- GetValue(_PathToGet: Text): Text
- SetValue(_PathToSet: Text; _NewValue: Text)
SetValueAsCData(_PathToSet: Text; _NewXmlCData: XmlCData)
SetValueAsCData(_PathToSet: Text; _NewCDataValue: Text)
Ns WhseInquiry Element (Accessor table, AL)
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:
...
... for new (custom) tags with no preexisting Get/Set-methods:
...
SetValueAsCData(_PathToSet: Text; _NewXmlCData: XmlCData)
...
Introduction
With Business Central you use the the extension model.
- The underlying Mobile WMS source code is now sealed and can no longer be modified directly.
- You create new objects, and extend existing objects depending on what you want your extension to do.
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 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;