Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Use this event to:

Excerpt

Handle Custom Registration Type for Adhoc PostRegistrationConfiguration Document Type.

Extract values from XML Request Doc and handle business logic for the Custom Registration Type.

If you are using MOB5.15 (or newer) consider using the event instead.

Template

...

          // 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

Use this event to:

Excerpt

Handle custom Unplanned Functions business logic using XmlDom.



If you are using MOB5.15 (or newer) consider using the OnPostAdhocRegistrationOnCustomRegistrationType event instead.


Template

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Adhoc RegistrMOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml', '', true true, true true)]
    local procedure OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml(var  OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml(_MessageId: Guidvar _XMLRequestDoc: XmlDocument; var _XMLResponseDoc: XmlDocument; _RegistrationType: Text; var _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
    var
        MobDocQueue:     MOBToolbox: Codeunit "MOB ToolboxRecord "MOB Document Queue";
        MOBToolbox: Codeunit "MOB Toolbox";
     Status        Status: Text;
    begin
          if   if_RegistrationType RegistrationType = 'SetWhseClassCodeMyCustomRegistrationType' then begin           // Replace constant 'MyCustomRegistrationType' with your own RegistrationType
            if          if _IsHandled then
               exit;          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: Codeunit "MOB XML Management";
     MobToolbox: Codeunit "MOB Toolbox";
     MobWMSToolbox: Codeunit "MOB WMS Toolbox";
     MobWmsLanguage: Codeunit "MOB WMS Language";
     XMLRequestNode: XmlNode;
     XMLRequestDataNode: XmlNode;
     XMLParameterNode: XmlNode;
     XMLNodesList: XMLNodeList;
     ItemNumber: Code[20];
     i: Integer;
     WhseClassCode: Code[10];
begin
     // Extract any parameters from the XML
     // The parameters are located in the <requestData> element
     MobXMLMgt.GetDocRootNode(_XMLRequestDoc, XMLRequestNode);
     MobXMLMgt.FindNode(XMLRequestNode, MobWMSToolbox."CONST::requestData"(), 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.GetNodeChildNodes(XMLRequestDataNode, XMLNodesList);
     for i := 1 to XMLNodesList.Count() do begin
          MobXMLMgt.GetListItem(XMLNodesList, XMLParameterNode, (i)); // AL = 1 based index
          case MobXMLMgt.GetNodeName(XMLParameterNode) of
               'ItemNumber':
                    ItemNumber := MobWMSToolbox.GetItemNumber(MOBToolbox.ReadMisc(MobXMLMgt.GetNodeInnerText(XMLParameterNode)));
               'WhseClassCode':
                    WhseClassCode := MobXMLMgt.GetNodeInnerText(XMLParameterNode);
          end;
     end;
     _ReturnRegistrationTypeTracking := 'SetWhseClassCode: ' +
                                                                 Item.TableCaption() + ' ' +
                                                                 ItemNumber + ' ' +
                                                                 Item.FieldCaption("Warehouse Class Code") + ' ' +
                                                                 WhseClassCode;
     // Perform the posting
     if not Item.GET(ItemNumber) then
          ERROR(STRSUBSTNO(_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::CodeunitCodeunit::"MOB WMS Adhoc Registr.", 'OnPostAdhocRegistrationOnCustomRegistrationTypeAsXml''', true, true)]
    local procedure MyOnPostAdhocRegistrationOnCustomRegistrationTypeAsXml(var _XMLRequestDoc: XmlDocumentvar _XMLResponseDoc: XmlDocument; _RegistrationType: Textvar _RegistrationTypeTracking: Text[200]; var _IsHandled: Boolean)
    var
        MOBToolbox: Codeunit "MOB Toolbox";
        Status: Text;
    begin
        if _RegistrationType = 'SetWhseClassCode' then begin
            if _IsHandled then
                exit;

            Status := PostSetWhseClassCodeRegistration(_XMLRequestDoc, _RegistrationTypeTracking);
            MOBToolbox.CreateSimpleResponse(_XMLResponseDoc, Status);

            _IsHandled := true;
        end;
    end;

    procedure PostSetWhseClassCodeRegistration(_XMLRequestDoc: XmlDocumentvar _ReturnRegistrationTypeTracking: Text[200])Text[60];
    var
        Item: Record Item;
        MobXmlMgt: Codeunit "MOB XML Management";
        MobWmsToolbox: Codeunit "MOB WMS Toolbox";
        MobWmsLanguage: Codeunit "MOB WMS Language";
        XmlRequestNode: XmlNode;
        XmlRequestDataNode: XmlNode;
        XmlParameterNode: XmlNode;
        XmlNodesList: XMLNodeList;
        ItemNumber: Code[50];
        i: Integer;
        WhseClassCode: Code[10];
    begin
        // Extract any parameters from the XML
        // The parameters are located in the <requestData> element
        MobXmlMgt.GetDocRootNode(_XMLRequestDoc, XmlRequestNode);
        MobXmlMgt.FindNode(XmlRequestNode, MobWmsToolbox."CONST::requestData"(), 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.GetNodeChildNodes(XmlRequestDataNode, XmlNodesList);
        for i := 1 to XmlNodesList.Count() do begin
            MobXmlMgt.GetListItem(XmlNodesList, XmlParameterNode, (i))// AL = 1 based index
            case MobXmlMgt.GetNodeName(XmlParameterNodeof
                'ItemNumber':
                    ItemNumber := MobWmsToolbox.GetItemNumber(CopyStr(MobXmlMgt.GetNodeInnerText(XmlParameterNode)1, MaxStrLen(ItemNumber)));
                'WhseClassCode':
                    WhseClassCode := CopyStr(MobXmlMgt.GetNodeInnerText(XmlParameterNode)1, MaxStrLen(WhseClassCode));
            end;
        end;

        _ReturnRegistrationTypeTracking := 'SetWhseClassCode: ' +
                                                                    Item.TableCaption() ' ' +
                                                                    ItemNumber + ' ' +
                                                                    Item.FieldCaption("Warehouse Class Code"' ' +
                                                                    WhseClassCode;

        // Perform the posting
        if not Item.Get(ItemNumberthen
            Error(MobWmsLanguage.GetMessage('ITEM_EXIST_ERR'), ItemNumber), ItemNumber);
     if WhseClassCode <> Item
        if WhseClassCode <> Item."Warehouse Class CodeWarehouse Class Code" then begin
          Item            Item.Validate("Warehouse Class CodeWarehouse Class Code", WhseClassCode WhseClassCode);
          Item            Item.Modify(true);
     end        end;
     exit(STRSUBSTNO('Warehouse Class Code set for %1', ItemNumber
        exit(CopyStr(StrSubstNo('Warehouse Class Code set for %1', ItemNumber)160));
    end;

Version History

VersionChanges
MOB5.00Introduced
MOB5.17New parameter _MessageId