Whitepaper Custom XML Response Extensions

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::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAfterSetFromAnyLine''', true, true)]

procedure OnReceiveOnAfterSetFromAnyLine(_RecRef: RecordRefvar _BaseOrderLineElement: Record "MOB Ns BaseDataModel Buffer")
begin
     // Under-/OverDeliveryValidation - The choices are: None, Warn, Block
     _BaseOrderLineElement.Set_UnderDeliveryValidation('Block');
end;