ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Change Request] Codeunit 80 Sales Post - procedure PostUpdateReturnReceiptLine - Event OnAfterPostUpdateReturnReceiptLine

Open MH1612 opened this issue 2 years ago • 9 comments

Describe the request

We would like var SalesHeader added to the following event.

Original:

Codeunit 80 Sales Post - procedure PostUpdateReturnReceiptLine - Event OnAfterPostUpdateReturnReceiptLine

    local procedure PostUpdateReturnReceiptLine()
    var
        SalesOrderLine: Record "Sales Line";
        ReturnRcptLine: Record "Return Receipt Line";
        TempSalesLine: Record "Sales Line" temporary;
        IsHandled: Boolean;
    begin

    ...

    OnAfterPostUpdateReturnReceiptLine(TempSalesLine);

    [IntegrationEvent(true, false)]
    local procedure OnAfterPostUpdateReturnReceiptLine(var TempSalesLine: Record "Sales Line" temporary)
    begin
    end;

Change:

Codeunit 80 - Sales Post - procedure PostUpdateReturnReceiptLine - Event OnAfterPostUpdateReturnReceiptLine

    local procedure PostUpdateReturnReceiptLine(var SalesHeader: Record "Sales Header")
    // similar to PostUpdateInvoiceLine
    var
        SalesOrderLine: Record "Sales Line";
        ReturnRcptLine: Record "Return Receipt Line";
        TempSalesLine: Record "Sales Line" temporary;
        IsHandled: Boolean;
    begin

    ...

    OnAfterPostUpdateReturnReceiptLine(TempSalesLine, SalesHeader);

    [IntegrationEvent(true, false)]
    procedure OnAfterPostUpdateReturnReceiptLine(var TempSalesLine: Record "Sales Line" temporary; var SalesHeader: Record "Sales Header")
    begin
    end;

Additional context

Post Invoice with Return Receipts Internal work item: AB#523918

MH1612 avatar Mar 27 '24 06:03 MH1612

In what localization we have SalesHeader parameter in procedure PostUpdateReturnReceiptLine?

tomasevicst avatar Apr 10 '24 12:04 tomasevicst

@tomasevicst It relates to this request: https://github.com/microsoft/ALAppExtensions/issues/26195

image

MH1612 avatar Apr 10 '24 12:04 MH1612

Hello @MH1612 Related to a request #26195 - it is completed with PostUpdateReturnReceiptLine become public. So, does the current request still have a purpose?

AleksandricMarko avatar Jul 15 '24 12:07 AleksandricMarko

Hi @AleksandricMarko,

yes, the current request is still needed. We still need the Sales Header parameter in the OnAfterPostUpdateReturnReceiptLine-Event.

SKeiler avatar Jul 17 '24 13:07 SKeiler

Hello @SKeiler @MH1612 Now that the procedure is public, adding a new parameter will break any extension that is using it. There is the event OnBeforeInsertTrackingSpecification(SalesHeader: Record "Sales Header", var TempTrackingSpecification: Record "Tracking Specification" temporary, var IsHandled: Boolean) which is raised in the procedure InsertTrackingSpecification(SalesHeader: Record "Sales Header"), called right after the event you mentioned. We could change the parameters so that the SalesHeader is passed by reference (with var).

Would this work for you? The result would be virtually the same, except we avoid modifying a public procedure.

attilatoury avatar Mar 26 '25 09:03 attilatoury

Hi @attilatoury ,

it's a little bit curious, because we requested the global scope of the procedure. So because of that event request is published earlier, the other request is not possible anymore... :-( Isn't the right way to add a secord procedure with the new parameter and set the old procedure to obsolete (which uses a Dummy Sales Header)?!

For our solution I have to do a deeper source code check. On the first view it is a little bit complicated, because the InsertTrackingSpecification-procedure is called different times and not only after the PostUpdateReturnReceiptLine-Call. Also the InsertTrackingSpecification-procedure get's the Sales Header not with VAR-Flag (that would be the same problem). But when I check the SalesHeader-usage of the PostUpdateInvoiceLine-procedure (which we want to call from the event) it seems like to only be used from events.

SKeiler avatar Jun 04 '25 19:06 SKeiler

Hello @SKeiler

Have you checked if you could work around the issue using the event from OnBeforeInsertTrackingSpecification? You could perform some checks in the subscriber to ensure you are getting the correct SalesHeader. You can also try to get the record using the TempSalesLine emitted in the OnAfterPostUpdateReturnReceiptLine event.

These suggestions would help us avoid modifying the public procedure.

attilatoury avatar Jun 19 '25 08:06 attilatoury

@attilatoury: Sorry, I didn't had the time to check this. But I would propose that you can close the issue and we would open a new one, if we need changes :-)

SKeiler avatar Jun 20 '25 08:06 SKeiler

@SKeiler Okay, I will do that. Thanks for your answer

attilatoury avatar Jun 20 '25 11:06 attilatoury