Versions Compared

Key

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

Case

...

Case

Excerpt

Scan ExpirationDate as custom format YYYYMM when goods is received from any Vendor.



Proposed solution

Scan ExpirationDate as new text field in custom format YYYYMM when items is received from any Vendor. The change must be in effect for all four receive document types (:

  • Warehouse Receipt

...

  • Purchase Order

...

  • Transfer Receipt

...

  • Sales Return Order

Disable standard Expiration Date step due to this always being validated as date format, then create a new custom step validated from a regular expression. This regular expression must validate year as "20 + two digits" and month as "0 + one digit" or "10", "11" or "12".

When saving RegistrationData, the new custom ExpirationDate should be used when creating the RegistrationData-entry. The RegistrationData."Expiration Date" will be used by Mobile WMS posting functions with no further changes.

Example

    //
    // Scan ExpirationDate as new text field in custom format YYYYMM when items is received from any Vendor.
    // Disable standard Expiration Date step due to this always being validated as date format, then create a new custom step validated from a regular expression.
    // When saving RegistrationData, the new custom ExpirationDate should be used if exists.
    //

    //
    // Create new RegistrationCollectorConfiguration-Key in reference data with one new step named "CustomExpirationDate"
    // 
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Reference Data", 'OnGetReferenceData_OnAfterAddRegistrationCollectorConfigurationsAsXml''', true, true)]
    local procedure OnGetReferenceData_OnAfterAddRegistrationCollectorConfigurationsAsXml(var _XmlResponseData: XmlNode)
    var
        MobXmlMgt: Codeunit "MOB XML Management";
        XmlConfigurationNode: XmlNode;
        XmlKeyNode: XmlNode;
        XmlValueNode: XmlNode;
        XmlCDataSection: XmlCdata;
    begin
          // Add the mandatory nodes
        MobXmlMgt.AddElement(_XmlResponseData, 'Configuration''''', XmlConfigurationNode);
        MobXmlMgt.AddElement(XmlConfigurationNode, 'Key''MyCustomSteps''', XmlKeyNode);
        MobXmlMgt.AddElement(XmlConfigurationNode, 'Value''''', XmlValueNode);

        // Add the CDATA section to the Value-Node
        XmlCDataSection := GetOrderLineExtraInfoCDataSection();
        MobXMLMgt        MobXmlMgt.NodeAppendCData(XmlValueNode, XmlCDataSection);
    end;

    local procedure GetOrderLineExtraInfoCDataSection() XmlCDataSection: XmlCdata
    var
        MobXmlMgt: Codeunit "MOB XML Management";
        MobConfTools: Codeunit "MOB WMS Conf. Tools";
        DummyXmlDocument: XmlDocument;
        RegexExpr: Text[1024];
    begin
        // Create an empty CDATA section to add the registrationCollectorConfiguration XML to
        MobXmlMgt.NodeCreateCData(DummyXmlDocumentXmlCDataSection, XmlCDataSection, '');

        // Create the start tags of the configuration xml. These must be closed afterwards.
        MobXMLMgt        MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '<registrationCollectorConfiguration>');
        MobXMLMgt        MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '<steps>');

        // Add the actual steps
        RegexExpr := '(20[0-4]\d)(0[1-9]|1[0-2])';  // "20"+ remaining two digits in year then two digit month (0+single digit or 10, 11 or 12)
        MobConfTools.RC_Std_Parms(10000'MyExpirationDate''Expiration Date (YYYYMM)''Expiration Date:''Expiration Date in format YYYYMM');
        MobConfTools.RC_Ext_Parms_InputFormat(RegexExpr);
        MobConfTools.RC_Text_CData(XmlCDataSection, ''6);
        MobXMLMgt
        MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '</steps>');
        MobXMLMgt        MobXmlMgt.NodeAppendCDataText(XmlCDataSection, '</registrationCollectorConfiguration>');

        exit(XmlCDataSection);
    end;

    //
    // Add steps referenced by new RegistrationCollectorConfiguration-Key to line steps collectors
    //
    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Receive", 'OnGetReceiveOrderLines_OnAddStepsToAnyLine''', true, true)]
    local procedure OnGetReceiveOrderLines_OnAddStepsToAnyLine(_RecRef: RecordRefvar _BaseOrderLineElement: Record "MOB Ns BaseDataModel Element")
    begin
        with _BaseOrderLineElement do
                begin
        // MOB5.11
                    // Currently the Android Mobile App supports only one "RegisterExtraInfo"-node (one extra RegistrationCollectorConfigurationKey).
                    // The last subscriber to OnGetReceiveOrderLines_OnAfterAddStepsByReferenceDataKey must set a <RegisterExtraInfo>-key that includes steps for all previous subscribers.
                    // This is only possible by knowing what other customizations is done and manually create a new RegistrationCollectorConfigurationKey that includes all steps.
                    // 
                    // In this demo we expect to be only subscriber and throw an error if earlier subscribtions exists by including optional _ErrorIfAlreadyCreated parameter.
                    // We cannot test if later subcribers is overriding this value we set.
            if Get        if _BaseOrderLineElement.Get_RegisterExpirationDate() 'true' then begin
                Set            _BaseOrderLineElement.Set_RegisterExpirationDate(false);       // Disable the standard (date format) expiration date step
                Create Disable the standard (date format) expiration date step
            _BaseOrderLineElement.Create_StepsByReferenceDataKey('MyCustomSteps', true);  // This key must include MyExpirationDate-step but may include other steps as well
                    end;
    end;

    [EventSubscriber(ObjectType::CodeunitCodeunit::"MOB WMS Toolbox", 'OnSaveRegistrationValue''', true, true)]
    local procedure OnSaveRegistrationValue(_Path: Text; _Value: Textvar _MobileWMSRegistration: Record "MOB WMS Registration"; var _IsHandled: Boolean)
    var
        Year: Integer;
        Month: Integer;
    begin
        if _Path <> 'MyExpirationDate' then
            exit;

        if _Value <> '' then begin
            Evaluate(Year, CopyStr(_Value, 14));
            Evaluate(Month, CopyStr(_Value, 52));
            _MobileWMSRegistration."Expiration Date" := DMY2Date(01, Month, Year);
        end else
            _MobileWMSRegistration."Expiration Date" := 0D;

        _IsHandled := true;
    end;

Version History

VersionChanges
MOB5.11Neccessary events introduced