microsoft / ALAppExtensions

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

[Event Request] Table 36 "Sales Header" - procedure PerformManualRelease #26985

Closed dorinbirsan closed 2 weeks ago

dorinbirsan commented 1 month ago

Describe the request

Describe the request

The current change would benefit the fact that we could handle the code from the procedure PerformManualRelease inside "Sales Header" table.

Current:

    internal procedure PerformManualRelease()
    var
        ReleaseSalesDoc: Codeunit "Release Sales Document";
    begin
        if Rec.Status <> Rec.Status::Released then begin
            ReleaseSalesDoc.PerformManualRelease(Rec);
            Commit();
        end;
    end;

Requested:

    ...

    internal procedure PerformManualRelease()
    var
        ReleaseSalesDoc: Codeunit "Release Sales Document";
        IsHandled: Boolean;
    begin
        OnBeforePerformManualRelease(Rec, IsHandled);
        if IsHandled then
            exit;

        if Rec.Status <> Rec.Status::Released then begin
            ReleaseSalesDoc.PerformManualRelease(Rec);
            Commit();
        end;
    end;

    ...

    [IntegrationEvent(false, false)]
    local procedure OnBeforePerformManualRelease(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)
    begin
    end;

    ...

Additional context

Justification: we request the event since in BC22 it was introduced that in the actions Create Warehouse Shipment and Create Warehouse receipt the document is released automatically in case it was open. That conflicts now with existing custom logic, that the warehouse document is created already after the release of a document, leading to the issue that it is now tried two times to create the warehouse document. Internal work item: AB#544596

AleksandricMarko commented 1 month ago

Hello @dorinbirsan Why do not you can use existing OnBeforePerformManualReleaseProcedure (codeunit 414 "Release Sales Document")

dorinbirsan commented 4 weeks ago

Hello @Ale

Hello @dorinbirsan Why do not you can use existing OnBeforePerformManualReleaseProcedure (codeunit 414 "Release Sales Document")

We cannot really use the OnBeforePerformManualReleaseProcedure (codeunit 414 "Release Sales Document") because there is a Status check before triggering this event.

The context is the following: We are using the action "Create &Warehouse Shipment" and inside the OnAction trigger you have the Rec.PerformManualRelease(); function call. If the Status is however 'Released' then it does no longer get inside the event OnBeforePerformManualReleaseProcedure and then we cannot handle it.

The idea is that even if the status is Released on the SalesHeader, and in the meantime a user deleted the WhseShipment, then when the user clicks on the action "Create &Warehouse Shipment", we will still be able to subscribe to this new event so that we can properly handle a specific behavior with the help of a manualsubscriber codeunit.

image

JesperSchulz commented 2 weeks 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: 23666.