Use this event to:
Excerpt |
---|
Handle custom Unplanned Functions business logic using XmlDom. |
...
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml', '', true, true)]
local procedure OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml(_MessageId: Guid; var _XMLRequestDoc: XmlDocument; var _XMLResponseDoc: XmlDocument; _RegistrationType: Text; var _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
var
MobDocQueue: Record "MOB Document Queue";
MOBToolbox: Codeunit "MOB Toolbox";
Status: Text;
begin
if _RegistrationType = 'MyCustomRegistrationType' then begin // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
if _IsHandled then
exit;
// Add your business logic here
// .....
// Optional: Read MobDocQueue to i.e. read device id
MobDocQueue.GetByGuid(_MessageId, MobDocQueue);
// Always return a response text to the front-end
Status := 'OK';
MOBToolbox.CreateSimpleResponse(_XMLResponseDoc, Status);
// Return that this registration type was handled
_IsHandled := true;
end;
end;
Example
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml', '', true, true)]
local procedure MyOnPostAdhocRegistrationOnCustomRegistrationTypeAsXml(var _XMLRequestDoc: XmlDocument; var _XMLResponseDoc: XmlDocument; _RegistrationType: Text; var _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
var
MOBToolbox: Codeunit "MOB Toolbox";
Status: Text;
begin
if _RegistrationType = 'SetWhseClassCode' then begin
if _IsHandled then
exit;
Status Status := PostSetWhseClassCodeRegistration(_XMLRequestDoc, _RegistrationTypeTracking);
MOBToolbox.CreateSimpleResponse(_XMLResponseDoc, Status);
_IsHandled := true;
end;
end;
procedure PostSetWhseClassCodeRegistration(_XMLRequestDoc: XmlDocument; var _ReturnRegistrationTypeTracking: Text[200]): Text[60];
var
Item: Record Item;
MobXMLMgt MobXmlMgt: Codeunit "MOB XML Management";
MobToolbox MobWmsToolbox: Codeunit "MOB Toolbox";
MobWMSToolbox: Codeunit "MOB WMS Toolbox";
MobWmsLanguage: Codeunit "MOB WMS Language";
XMLRequestNode XmlRequestNode: XmlNode;
XMLRequestDataNode XmlRequestDataNode: XmlNode;
XMLParameterNode XmlParameterNode: XmlNode;
XMLNodesList XmlNodesList: XMLNodeList;
ItemNumber: Code[2050];
i: Integer;
WhseClassCode: Code[10];
begin
// Extract any parameters from the XML
// The parameters are located in the <requestData> element
MobXMLMgt MobXmlMgt.GetDocRootNode(_XMLRequestDoc, XMLRequestNode XmlRequestNode);
MobXMLMgt MobXmlMgt.FindNode(XMLRequestNodeXmlRequestNode, MobWMSToolbox MobWmsToolbox."CONST::requestData"(), XMLRequestDataNode XmlRequestDataNode);
// Loop over the registration values. We don't know which values will be present because it is configurable
// The values are added to the relevant journal if they have been registered on the mobile device
MobXMLMgt MobXmlMgt.GetNodeChildNodes(XMLRequestDataNodeXmlRequestDataNode, XMLNodesList XmlNodesList);
for i := 1 to XMLNodesList XmlNodesList.Count() do begin
MobXMLMgt MobXmlMgt.GetListItem(XMLNodesListXmlNodesList, XMLParameterNode XmlParameterNode, (i)); // AL = 1 based index
case MobXMLMgt MobXmlMgt.GetNodeName(XMLParameterNodeXmlParameterNode) of
'ItemNumber':
ItemNumber := MobWMSToolboxMobWmsToolbox.GetItemNumber(CopyStr(MOBToolboxMobXmlMgt.ReadMisc(MobXMLMgt.GetNodeInnerText(XMLParameterNode)XmlParameterNode), 1, MaxStrLen(ItemNumber)));
'WhseClassCode':
WhseClassCode := CopyStr(MobXMLMgtMobXmlMgt.GetNodeInnerText(XMLParameterNodeXmlParameterNode), 1, MaxStrLen(WhseClassCode));
end;
end;
_ReturnRegistrationTypeTracking := 'SetWhseClassCode: ' +
Item.TableCaption() + ' ' +
ItemNumber + ' ' +
Item.FieldCaption("Warehouse Class Code") + ' ' +
WhseClassCode;
// Perform the posting
if not Item.GETGet(ItemNumber) then
ERROR Error(STRSUBSTNO(MobWmsLanguage.GetMessage('ITEM_EXIST_ERR'), ItemNumber));
if WhseClassCode <> Item."Warehouse Class Code" then begin
Item.Validate("Warehouse Class Code", WhseClassCode);
Item.Modify(true);
end;
exit(STRSUBSTNOCopyStr(StrSubstNo('Warehouse Class Code set for %1', ItemNumber), 1, 60));
end;
Version History
Version | Changes |
---|---|
MOB5.00 | Introduced |
MOB5.17 | New parameter _MessageId |
...