OnSynchronizePackageTypes

Use this event to

Synchronize master data for Package Types from 3rd party Shipping App to Tasklet Pack and Ship


Description

Package Types including their default Dimensions and Unit of Measures. 

Imported Package Types will be available in Pack & Ship setup tables and in that way can be exposed on mobile devices.

See: Read master data from 3rd party Shipping App

Template

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Pack API", 'OnDiscoverShippingProvider', '', true, true)]
    local procedure OnDiscoverShippingProvider()
    begin
    end;


Example

    /// <summary>
    /// Interface implementation: Synchronize package types from external solution to our own internal table
    /// </summary>  
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"MOB Pack API", 'OnSynchronizePackageTypes', '', true, true)]
    local procedure MyOnSynchronizePackageTypes(var _PackageType: Record "MOB Package Type")
    begin
        SynchronizePackageTypes(_PackageType);
    end;

    
    internal procedure SynchronizePackageTypes(var _PackageType: Record "MOB Package Type")
    var
        ExternalPackageType: Record "External Package Type";    // Package Type table in 3rd Party App
    begin
        ExternalPackageType.Reset();
        if ExternalPackageType.FindSet() then
            repeat
                _PackageType.Init();
                _PackageType.Validate(Code, '');
                _PackageType.Validate("Shipping Provider Id", GetShippingProviderId());
                _PackageType.Validate("Shipping Provider Package Type", ExternalPackageType.Code);
                _PackageType.Validate(Description, CopyStr(ExternalPackageType.Description, 1, MaxStrLen(_PackageType.Description)));
                _PackageType.Validate(Default, ExternalPackageType.Default);
                _PackageType.Validate(Unit, ExternalPackageType.Type);
                _PackageType.Validate(Height, ExternalPackageType.Height);
                _PackageType.Validate(Width, ExternalPackageType.Width);
                _PackageType.Validate(Length, ExternalPackageType.Length);
                _PackageType.Validate(Weight, ExternalPackageType.Weight);
                if _PackageType.Insert(true) then;  // Package Type may already exist                
            until ExternalPackageType.Next() = 0;
    end;

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

Version History

VersionChanges
MOB5.42Introduced