[Event Request] Codeunit 5814 "Undo Return Shipment Line" - Code procedure
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
Why do you need this change?
Event Request: OnCodeOnBeforeMakeInventoryAdjustment
Please add a new integration event in the Code() procedure of codeunit 5814 "Undo Return Shipment Line", right before the MakeInventoryAdjustment() call, just after UnbindSubscription(this).
Codeunit 5813 "Undo Purchase Receipt Line" already has this event, called OnCodeOnBeforeMakeInventoryAdjustment(PurchLine, PurchRcptLine), in the same spot, and we already subscribe to it there. Codeunit 5814 does the same kind of undo work - undo loop, unbind the subscription, then call MakeInventoryAdjustment() - and we want to run the same logic on it, but it has no matching event to subscribe to.
Alternatives Evaluated
- Subscribing to an earlier event in the same procedure (e.g.
OnAfterReturnShptLineModify): This fires once per line, inside the undo loop, beforeUnbindSubscription(this). It doesn't give us one hook that runs after all lines are done and right beforeMakeInventoryAdjustment(), so it can't do the same job asOnCodeOnBeforeMakeInventoryAdjustmenton codeunit 5813. - Subscribing to
MakeInventoryAdjustment()itself: This runs inside the shared adjustment routine, afterItemsToAdjusthas already been built, and doesn't give us access toReturnShptLine/SalesLinethe way the requested event would. - Copying the whole codeunit into our own version: This would work, but it means keeping a ~150-line copy of base app code in sync with every base app update, which is exactly what integration events are meant to avoid.
None of these give us the same timing as OnCodeOnBeforeMakeInventoryAdjustment on codeunit 5813, which is why we're asking for the same event on codeunit 5814.
Performance Considerations
The event only fires once per call to Code() (once per Undo Return Shipment Line action), not once per line, so it adds almost no overhead. This matches how the existing event already behaves on codeunit 5813. If nobody subscribes to it, it's just an empty call and does nothing.
Data Sensitivity Review
The event passes SalesLine and ReturnShptLine by var, and both are already fully available to whoever runs Undo Return Shipment Line in the first place. Nothing new or sensitive is exposed - no customer, vendor, or financial data beyond what's already on the return shipment line.
Multi-Extension Interaction
Since the parameters are passed by var, more than one extension could subscribe and change SalesLine/ReturnShptLine before MakeInventoryAdjustment() runs, so if two extensions touch the same fields, the order they run in could matter. This is the same situation that already exists with OnCodeOnBeforeMakeInventoryAdjustment on codeunit 5813, so it doesn't introduce any new kind of conflict.
Describe the request
Current code in Code():
until ReturnShptLine.Next() = 0;
UnbindSubscription(this);
MakeInventoryAdjustment();
Requested change:
until ReturnShptLine.Next() = 0;
UnbindSubscription(this);
//>> code change start
OnCodeOnBeforeMakeInventoryAdjustment(SalesLine, ReturnShptLine);
//<< code change end
MakeInventoryAdjustment();
New event declaration:
[IntegrationEvent(false, false)]
local procedure OnCodeOnBeforeMakeInventoryAdjustment(var SalesLine: Record "Sales Line"; var ReturnShptLine: Record "Return Shipment Line")
begin
end;
(SalesLine is already declared as a local variable in Code(), matching the PurchLine parameter used in the equivalent event on codeunit 5813.)
Same spot in codeunit 5813, for comparison
Codeunit 5813 "Undo Purchase Receipt Line" already has this event in its Code() procedure, in the exact same spot - right after UnbindSubscription(this) and right before MakeInventoryAdjustment():
until PurchRcptLine.Next() = 0;
UnbindSubscription(this);
OnCodeOnBeforeMakeInventoryAdjustment(PurchLine, PurchRcptLine);
MakeInventoryAdjustment();
This is the existing event declaration on codeunit 5813:
[IntegrationEvent(false, false)]
local procedure OnCodeOnBeforeMakeInventoryAdjustment(var PurchLine: Record "Purchase Line"; var PurchRcptLine: Record "Purch. Rcpt. Line")
begin
end;
We're asking for the exact same event, at the exact same point, just for codeunit 5814, using its own SalesLine/ReturnShptLine instead of PurchLine/PurchRcptLine.
Provide an implementation (optional)
- I will provide the implementation for this extensibility request
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate codeunit 5814 "Undo Return Shipment Line" and compare its Code() procedure with codeunit 5813 "Undo Purchase Receipt Line". Add the requested event invocation after UnbindSubscription(this) and before MakeInventoryAdjustment(), along with the matching declaration; done means the extension compiles and the event is available at that point.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100