Versions Compared

Key

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

Use this event to

Excerpt

Handle a Lookup request for a custom LookupType using XmlDom.

...

If you are using MOB5.29 (or newer) consider using the OnLookupOnCustomLookupType event instead.
If you are using MOB5.21 -MOB5.28 consider using the (Legacy) OnLookupOnCustomLookupType (MOB5.21 - MOB5.28) event instead.

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::CodeunitCodeunit::"MOB WMS Lookup", 'OnLookupOnCustomLookupTypeAsXml''', true, true)]
    local procedure OnLookupOnCustomLookupTypeAsXml(var _XmlRequestDoc: XmlDocument; _LookupType: Text[50]; var _XmlResultDoc: XmlDocumentvar _IsHandled: Boolean)
    begin
    end;


Example

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Lookup", 'OnLookupOnCustomLookupTypeAsXml''', true, true)]
    local procedure MyOnLookupOnCustomLookupTypeAsXml(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;
        MobWmsLookup: Codeunit "MOB WMS Lookup";
        MobToolbox: Codeunit "MOB Toolbox";
        MobWmsToolbox: Codeunit "MOB WMS 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
        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(CopyStr(MobToolbox.ReadEAN(MobXmlMgt.GetNodeInnerText(XmlParameterNode))120), VariantCode);

        // Initialize the response xml
        MobToolbox.InitializeResponseDocWithNS(_XmlResultDoc, XmlResponseData, CopyStr(MobXmlMgt.NS_WHSEMODEL()11024));

        // Determine if the item has substitutes
        ItemSubstitution.SetRange("No.", MobWmsToolbox.GetItemNumber(ItemNumber));
        ItemSubstitution.SetRange("Variant Code", VariantCode);

        if ItemSubstitution.FindSet() then
            repeat
                // Collect the buffer values for the <LookupResponse> element
                TempLookupResponseElement.Create();
                MyCustomSetFromLookupSubstituteItem(ItemSubstitution, TempLookupResponseElement);
                TempLookupResponseElement.Save();

            until ItemSubstitution.Next() 0;

        MobWmsLookup.AddLookupResponseElements(XmlResponseData, TempLookupResponseElement);
    end;

    localprocedure MyCustomSetFromLookupSubstituteItem(_ItemSubstitution: Record "Item Substitution"; var _LookupResponseElement: Record "MOB NS WhseInquery Element")
    var
        MobWmsLookup: Codeunit "MOB WMS Lookup";
        MobWmsLanguage: Codeunit "MOB WMS Language";
        MobWmsToolbox: Codeunit "MOB WMS Toolbox";
    begin
        _LookupResponseElement.Init();

        _LookupResponseElement.Set_Location('');
        _LookupResponseElement.Set_ItemNumber(_ItemSubstitution."Substitute No.");
        _LookupResponseElement.Set_Barcode('');

        _LookupResponseElement.Set_SerialNumber('');
        _LookupResponseElement.Set_LotNumber('');
        _LookupResponseElement.Set_Bin('');
        _LookupResponseElement.Set_Quantity(1);
        _LookupResponseElement.Set_UoM('');
        _LookupResponseElement.SetValue('MyCustomValue', 'My Custom Value');

        _LookupResponseElement.Set_DisplayLine1(_LookupResponseElement.Get_ItemNumber());
        _LookupResponseElement.Set_DisplayLine2(MobWmsToolbox.GetItemDescription(_ItemSubstitution."Substitute No.", _ItemSubstitution."Substitute Variant Code"));
        _LookupResponseElement.Set_DisplayLine3('');
        _LookupResponseElement.Set_DisplayLine4(_ItemSubstitution."Substitute Variant Code" <> '', MobWmsLanguage.GetMessage('VARIANT_LABEL') + ' ' + _ItemSubstitution."Substitute Variant Code", '');
        _LookupResponseElement.Set_DisplayLine5('Interchangeable: ' + MobWmsToolbox.Bool2TextAsDisplayFormat(_ItemSubstitution.Interchangeable));
    end;


Version History

VersionChanges
MOB5.38GetText replaced with new MobWmsToolbox.GetItemAndVariantDescription
MOB5.00Introduced

...