OnPostPackingOnCheckUntransferredLicensePlate

Use this event to

Validate untransferred License Plates prior to creating transactions in 3rd party Shipping App


Description

Use this event to validate untransferred License Plates (transaction data) stored in internal "Pack and Ship" tables prior to writing transaction data to the 3rd party Shipping App.

See also: Write Transaction Data to 3rd party Shipping App


Template

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Pack API", 'OnPostPackingOnCheckUntransferredLicensePlate', '', true, true)]
    local procedure OnPostPackingOnCheckUntransferredLicensePlate(_LicensePlate: Record "MOB License Plate")
    begin
    end;

Example

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Pack API", 'OnPostPackingOnCheckUntransferredLicensePlate', '', true, true)]
    local procedure MyOnPostPackingOnCheckUntransferredLicensePlate(_LicensePlate: Record "MOB License Plate")
    var
        CusExternalSetup: Record "CUS External Setup";
        CusExternalPackageType: Record "CUS External Package Type";
        PackageType: Record "MOB Package Type";
    begin
        if not IsShippingProvider(_LicensePlate."Package Type") then
            exit;

        // Check PackageType exists in 3rd party App and will not error out during validation        
        PackageType.Get(_LicensePlate."Package Type");
        CusExternalPackageType.Get(PackageType."Shipping Provider Package Type");

        // Check we are indeed supposed to create Transport Order from our code
        CusExternalSetup.Get();
        CusExternalSetup.TestField("After Posting Sales Orders", CusExternalSetup."After Posting Sales Orders"::"Do nothing");    // TODO - to be based on LicensePlate.Source Type and/or Whse. Document Type
    end;

    /// <summary>
    /// Is the package type handled by the current Shipping Provider Id
    /// </summary>  
    local procedure IsShippingProvider(_PackageType: Code[20]): Boolean
    var
        PackageType: Record "MOB Package Type";
    begin
        exit(PackageType.Get(_PackageType) and (PackageType."Shipping Provider Id" = GetShippingProviderId()));
    end;

    local procedure GetShippingProviderId(): Code[20]
    begin
        exit('MYSHIPPINGPROVIDERID');
    end;



Version History

VersionChanges
MOB5.42Introduced