microsoft / ALAppExtensions

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

[Event Modification] Codeunit 87 "Blanket Sales Order to Order" – OnBeforeCreateSalesHeader - Add additional var parameter SalesOrderHeader #26936

Closed andresteunenberg1964 closed 1 month ago

andresteunenberg1964 commented 1 month ago

Describe the request

Could you add the global variable SalesOrderHeader as a var parameter to the existing event OnBeforeCreateSalesHeader because we want to customize the filling of the global record variable SalesOrderHeader. On a side not: if in the current situation IsHandled would be set to True, the record variable SalesOrderHeader would not be assigned, which seems like a bug if this is not possible as in the subsequent code this global variable is used to created new Sales Order Lines.

local procedure CreateSalesHeader(SalesHeader: Record "Sales Header"; PrepmtPercent: Decimal) CreditLimitExceeded: Boolean
var
    StandardCodesMgt: Codeunit "Standard Codes Mgt.";
    IsHandled: Boolean;
begin
    IsHandled := false;

    // Old to be removed:
    // OnBeforeCreateSalesHeader(SalesHeader, PrepmtPercent, CreditLimitExceeded, IsHandled);

    // New as replacement:
    OnBeforeCreateSalesHeader(SalesHeader, PrepmtPercent, CreditLimitExceeded, IsHandled, SalesOrderHeader);

    if IsHandled then
        exit(CreditLimitExceeded);

Original Event: [IntegrationEvent(false, false)] local procedure OnBeforeCreateSalesHeader(var SalesHeader: Record "Sales Header"; PrepmtPercent: Decimal; var CreditLimitExceeded: Boolean; var IsHandled: Boolean) begin end;

Modified Event as replacement: [IntegrationEvent(false, false)] local procedure OnBeforeCreateSalesHeader(var SalesHeader: Record "Sales Header"; PrepmtPercent: Decimal; var CreditLimitExceeded: Boolean; var IsHandled: Boolean; var SalesOrderHeader: Record "Sales Header") begin end;

Additional context

For a customer with more than 1 blanket contract we want to have the possibility to create a Sales Order which consists of lines from different Blanket Orders (from the same customer). In that case the Sales Order Header must be created only once. Internal work item: AB#543331

azure-boards[bot] commented 1 month ago

✅ Successfully linked to Azure Boards work item(s):

JesperSchulz commented 1 month ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 22697.