microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
786 stars 621 forks source link

[Event Request] Codeunit 80 Sales Post - OnBeforeSellToCountry #10372

Closed Herodoteux closed 3 years ago

Herodoteux commented 3 years ago

Hi, in the Codeunit 80 Sales Post, would it be possible to get an event OnBeforeSellToCountry, like this : image

image

Thanks

StanPesotskiy commented 3 years ago

Clarify the placement of required event - on the picture it is inserted between functions. You help us implementing the requests faster when your request contains AL code copied from VSCode instead of screenshots.

Herodoteux commented 3 years ago

It's locate on the local procedure GetCountryCode image local procedure GetCountryCode(SalesLine: Record "Sales Line"; SalesHeader: Record "Sales Header"): Code[10] var SalesShipmentHeader: Record "Sales Shipment Header"; CountryRegionCode: Code[10]; IsHandled: Boolean; begin IsHandled := false; OnBeforeGetCountryCode(SalesHeader, SalesLine, CountryRegionCode, IsHandled); if IsHandled then exit(CountryRegionCode);

    if SalesLine."Shipment No." <> '' then begin
        SalesShipmentHeader.Get(SalesLine."Shipment No.");
        IsHandled := false;
        OnBeforeSaleShipmentHeader(SalesHeader, SalesShipmentHeader, SalesLine, IsHandled);
        if not IsHandled then
            exit(
              GetCountryRegionCode(
                SalesLine."Sell-to Customer No.",
                SalesShipmentHeader."Ship-to Code",
                SalesShipmentHeader."Sell-to Country/Region Code"));
    end;
    IsHandled := false;
    OnAfterGetCountryCode(SalesHeader, SalesLine, IsHandled);
    if not IsHandled then
        exit(
          GetCountryRegionCode(
            SalesLine."Sell-to Customer No.",
            SalesHeader."Ship-to Code",
            SalesHeader."Sell-to Country/Region Code"));
end;

_OnBeforeSellToCountry(SalesHeader, SalesLine, SalesShipmentHeader);___
StanPesotskiy commented 3 years ago

The line 5589: " end;" is the end of the function GetCountryCode. We cannot call an event outside of the function. You also want to name it OnBeforeSellToCountry though the function called GetCountryCode. What is the point?

Herodoteux commented 3 years ago

Yes sorry my mistake the event need to be in the procedure GetCountryCode mutch like this : image image Sorry it's because in navision there is not begin end in procedure

StanPesotskiy commented 3 years ago

You help us implementing the requests faster when your request contains AL code copied from VSCode instead of screenshots.

StanPesotskiy commented 3 years ago

The latest source code differs from code you described. You can use existent event OnBeforeGetCountryCode to overwrite the logic.