[Extensibility Request] issue 30352: add SkipNewExpirationDateCheck to OnCheckExpirationDateOnAfterCalcSumLot#9651
[Extensibility Request] issue 30352: add SkipNewExpirationDateCheck to OnCheckExpirationDateOnAfterCalcSumLot#9651AleksandricMarko wants to merge 1 commit into
Conversation
…ionDateOnAfterCalcSumLot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| else | ||
| SumLot := SignFactor * TempTrackingSpecification."Quantity (Base)"; | ||
| OnCheckExpirationDateOnAfterCalcSumLot(SumLot, SignFactor, TempTrackingSpecification); | ||
| if (SumOfEntries > 0) and |
There was a problem hiding this comment.
The pre-existing local IntegrationEvent "OnCheckExpirationDateOnAfterCalcSumLot" is retrofitted with a new "var SkipNewExpirationDateCheck: Boolean" parameter that, when a subscriber sets it true, causes the following TestField("New Expiration Date", ExistingExpirationDate) validation to be skipped entirely. This is the IsHandled bypass pattern applied to an existing shipped event rather than a new dedicated one: existing subscribers never agreed to make this check skippable, and the guarded TestField enforces expiration-date/lot-quantity consistency (a data-integrity validation), not a pure calculation. Per BCQuality guidance, critical validations like this should keep running unconditionally while only the SumLot calculation is exposed as overridable, or a new dedicated OnBefore event should be introduced instead of widening this event's contract.
Knowledge:
- microsoft/knowledge/events/do-not-bypass-critical-operations-with-ishandled.md
- microsoft/knowledge/events/do-not-add-ishandled-to-an-existing-event.md
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.13.4
| if (SumOfEntries > 0) and | ||
| SkipNewExpirationDateCheck := false; | ||
| OnCheckExpirationDateOnAfterCalcSumLot(SumLot, SignFactor, TempTrackingSpecification, SkipNewExpirationDateCheck); | ||
| if (not SkipNewExpirationDateCheck) and (SumOfEntries > 0) and |
There was a problem hiding this comment.
S1: Please add regression coverage proving that the default path still raises the existing expiration-date validation and that setting SkipNewExpirationDateCheck := true skips only this TestField without bypassing the rest of CheckExpirationDate.
qasimikram
left a comment
There was a problem hiding this comment.
The implementation is consistent across the W1 and localized code copies and scopes the bypass to the requested expiration-date validation.
S1: Please add regression coverage for the new subscriber-controlled path. The test should prove that the default path still raises the existing validation error and that setting SkipNewExpirationDateCheck := true skips only this TestField without bypassing the remainder of CheckExpirationDate.
Summary
The reporter needs a way to bypass the mandatory
New Expiration Datevalidation performed during item journal posting in codeunit 22 "Item Jnl.-Post Line". The existingOnBeforeCheckExpirationDate(IsHandled) event would force them to replicate the whole procedure and skip several downstream events, risking conflicts with other extensions. This PR extends the existingOnCheckExpirationDateOnAfterCalcSumLotintegration event with a newvar SkipNewExpirationDateCheck: Booleanparameter so a subscriber can skip only that singleTestFieldcheck without affecting any other logic.Source issue repository: microsoft/ALAppExtensions; issue number: 30352
Changes Made
OnCheckExpirationDateOnAfterCalcSumLot- appended a newvar SkipNewExpirationDateCheck: Booleanparameter to the integration event;CheckExpirationDatenow initializes it tofalse, passes it to the event, and only performsTempTrackingSpecification.TestField("New Expiration Date", ...)when the subscriber has not set it totrue. Adding a parameter to an existing integration event is non-breaking for current subscribers. The same change was mirrored across the W1 base layer and its country-layer counterparts (ES, APAC, CH, RU, IT).Fixes AB#642607