Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Handle a Lookup request for a custom LookupType unhandled by the standard Mobile WMS application.

Requires corresponding changes to Application.cfg to generate a Lookup-request including a new custom LookupType. 


Sample request:

<request name="Lookup" created="2018-12-06T15:23:00+01:00" xmlns="http://schemas.microsoft.com/Dynamics/Mobile/2007/04/Documents/Request">
     <requestData name="Lookup">
          <ItemNumber>1980-s</ItemNumber>
          <LookupType>MyCustomSubstituteItems</LookupType>
    </requestData>
</request>

Template:

[EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB WMS Lookup", 'OnLookupOnCustomLookupTypeAsXml', '', true, true)]
procedure OnLookupOnCustomLookupTypeAsXml(var _XmlRequestDoc: XmlDocument; _LookupType: Text[50]; var _XmlResultDoc: XmlDocument; var _IsHandled: Boolean)
begin
end;


Example:

[EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Lookup", 'OnLookupOnCustomLookupTypeAsXml''', true, true)]
procedure OnLookupOnCustomLookupTypeAsXml(var _XmlRequestDoc: XmlDocument; _LookupType: Text[50]; var _XmlResultDoc: XmlDocumentvar _IsHandled: Boolean)
begin
     if _LookupType = 'MyCustomSubstituteItems' then begin
          if _IsHandled then
               exit;

          MyCustomLookupSubstituteItems(_XmlRequestDoc, _XmlResultDoc);

          _IsHandled := true;
     end;
end;


local procedure MyCustomLookupSubstituteItems(_XmlRequestDoc: XmlDocumentvar _XmlResultDoc: XmlDocument);
var
     ItemSubstitution: Record "Item Substitution";
     TempLookupResponseElement: Record "MOB NS WhseInquery Element" temporary;
     TempValueBuffer: Record "MOB Value Buffer" temporary;
     MobWmsLookup: Codeunit "MOB WMS Lookup";
     MobWMSToolbox: Codeunit "MOB WMS Toolbox";
     MobBaseToolbox: Codeunit "MOB Toolbox";
     MobXmlMgt: Codeunit "MOB Xml Management";
     
XmlResponseData: XmlNode;
     
XmlRequestNode: XmlNode;
     
XmlRequestDataNode: XmlNode;
     
XmlParameterNode: XmlNode;
     
ItemNumber: Code[20];
     
VariantCode: Code[10];

begin

     // Extract any parameters from the XML
     // The parameters are located in the <requestData> element
     // The "Lookup bin content" supplies two parameters:
     // Location and Bin
     // The names of the XML elements are determined by the LookupBinContentConfiguration supplied as reference data
     MobXmlMgt.GetDocRootNode(_XmlRequestDoc, XmlRequestNode);
     MobXmlMgt.FindNode(XmlRequestNode, 'requestData', XmlRequestDataNode);

     
     // -- Now find the location parameter
     MobXmlMgt.FindNode(XmlRequestDataNode, 'ItemNumber', XmlParameterNode);
     // -- Get the parameter
     ItemNumber := MobWMSToolbox.CheckCrossRef(MobBaseToolbox.ReadEAN(MobXmlMgt.GetNodeInnerText(XmlParameterNode)), VariantCode);
     
     // Initialize the response xml
     MobBaseToolbox.InitializeResponseDocWithNS(_XmlResultDoc, XmlResponseData, MobXmlMgt.NS_WHSEMODEL());
     
     // Determine if the item has substitutes
     ItemSubstitution.SetRange("No.", MobWMSToolbox.GetItemNumber(ItemNumber));
     ItemSubstitution.SetRange("Variant Code", VariantCode);
     
     if ItemSubstitution.FindSet() then
          repeat
               with ItemSubstitution do begin
                    // Collect the buffer values for the <LookupResponse> element
                    TempLookupResponseElement.Create();
                    MyCustomSetFromLookupSubstituteItem(ItemSubstitution, TempLookupResponseElement);
                    TempLookupResponseElement.Save(TempValueBuffer);
               end;

          until ItemSubstitution.Next() 0;

     MobWmsLookup.AddLookupResponseElements(XmlResponseData, TempLookupResponseElement, TempValueBuffer);
end;

local procedure MyCustomSetFromLookupSubstituteItem(_ItemSubstitution: Record "Item Substitution"; var _LookupResponseElement: Record "MOB NS WhseInquery Element")
var
     Item: Record Item;
     ItemVariant: Record "Item Variant";
     MobWmsLookup: Codeunit "MOB WMS Lookup";
     MobWmsLanguage: Codeunit "MOB WMS Language";
     LineBuf: array[10of Text[250];
begin
     Item.Get(_ItemSubstitution."Substitute No.");
     
     // Populate LineBuf[1] and LineBuf[2] from details about the substitute
     Clear(LineBuf);
     if (_ItemSubstitution."Substitute Variant Code" <> '') and (ItemVariant.Get(_ItemSubstitution."Substitute No.", _ItemSubstitution."Substitute Variant Code")) then
          MobWmsLookup.GetText(ItemVariant.Description, ItemVariant."Description 2", LineBuf)
     else
          MobWmsLookup.GetText(Item.Description, Item."Description 2", LineBuf);
     
     with _LookupResponseElement do begin
          Init();
          
          Set_Location('');
          Set_ItemNumber(_ItemSubstitution."Substitute No.");
          Set_Barcode('');
          
          Set_SerialNumber('');
          Set_LotNumber('');
          Set_Bin('');
          Set_Quantity(1);
          Set_UoM('');
          SetValue('MyCustomValue''My Custom Value');
          
          Set_DisplayLine1(Get_ItemNumber());
          Set_DisplayLine2(LineBuf[1]);
          Set_DisplayLine3(LineBuf[2]);
          Set_DisplayLine4(_ItemSubstitution."Substitute Variant Code" <> '', MobWmsLanguage.GetMessage('VARIANT_LABEL'' ' + _ItemSubstitution."Substitute Variant Code", '');
          Set_DisplayLine5('Interchangeable: ' + FORMAT(_ItemSubstitution.Interchangeable));
          
          Set_ExtraInfo1('');
          Set_ExtraInfo2('');
          Set_ExtraInfo3('');
     end;
end;

Version History:

VersionChanges
MOB5.00Introduced
  • No labels