[Event Change Request] Codeunit 80 Sales Post - procedure PostUpdateReturnReceiptLine - Event OnAfterPostUpdateReturnReceiptLine
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
In what localization we have SalesHeader parameter in procedure PostUpdateReturnReceiptLine?
@tomasevicst It relates to this request: https://github.com/microsoft/ALAppExtensions/issues/26195
Hello @MH1612 Related to a request #26195 - it is completed with PostUpdateReturnReceiptLine become public. So, does the current request still have a purpose?
Hi @AleksandricMarko,
yes, the current request is still needed. We still need the Sales Header parameter in the OnAfterPostUpdateReturnReceiptLine-Event.
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.
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.
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: 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 Okay, I will do that. Thanks for your answer