Fix E-Document premature Commit during Inventory Pick posting#7132
Merged
Groenbech96 merged 7 commits intomainfrom Mar 18, 2026
Merged
Fix E-Document premature Commit during Inventory Pick posting#7132Groenbech96 merged 7 commits intomainfrom
Groenbech96 merged 7 commits intomainfrom
Conversation
The E-Document export path (EDocExport:399) executes an unconditional Commit() for error-isolation during XML generation. When called from posting event subscribers during an Inventory Pick, this commits the Sales Shipment and ILE before warehouse entries are created, causing an inventory-to-warehouse ledger mismatch if the bin check later fails. Changes: EDocumentSubscribers.Codeunit.al: - Add AllowCreateEDocument() guard to OnAfterPostSalesDoc, CreateEDocumentFromPostedTransferShipment, and OnAfterPostServiceDoc. Skips inline E-Document creation when CommitIsSuppressed, InvtPickPutaway, or PreviewMode is true. Logs telemetry on skip. - Add PreviewMode to CreateEDocumentFromPostedTransferShipment params (publisher already emits it). - Add OnAfterPostWhseActivHeader subscriber to create deferred E-Documents after the warehouse transaction completes. SubcWhseDirectPosting.Codeunit.al: - Accept new SuppressCommit and IsPreview parameters on OnAfterPostWhseActivHeader subscriber (no logic change). Bug: AB#625438 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The NAV PR obsoletes OnAfterPostWhseActivHeader (keeping original 4-param signature) and adds a new OnAfterPostWhseActivityCompleted event that fires after all posting work completes, including PostRelatedInboundTransfer. - E-Document subscriber: subscribe to new event instead of the old one - Subcontracting subscriber: revert to original 4-param signature since the old event retains its original contract Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The old OnAfterPostWhseActivHeader event is obsoleted and wrapped in #if not CLEAN29. Migrate the Subcontracting subscriber to the new event so it continues to work after the old event is removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The return values were swapped — normal posting (no flags) returned false (blocking creation) while deferred scenarios returned true (allowing it). Swap exit values so normal posting allows inline creation and suppressed flows correctly defer to OnAfterPostWhseActivityCompleted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts: # src/Apps/W1/EDocument/App/src/Processing/EDocumentSubscribers.Codeunit.al
aholstrup1
approved these changes
Mar 17, 2026
mazhelez
approved these changes
Mar 18, 2026
darjoo
approved these changes
Mar 18, 2026
Groenbech96
added a commit
that referenced
this pull request
Mar 18, 2026
Fix E-Document premature `Commit()` during Inventory Pick posting that causes data inconsistency (Bug 625438). When an Inventory Pick posts with an E-Document Service Flow configured, the E-Document export path executes an unconditional `Commit()` inside `OnAfterPostSalesDoc`. This commits the Sales Shipment and ILE before warehouse entries are created, causing an inventory-to-warehouse ledger mismatch if the warehouse bin check later fails. - Add `AllowCreateEDocument` guard to `OnAfterPostSalesDoc`, `OnAfterTransferOrderPostShipment`, and `OnAfterPostServiceDoc` subscribers to skip E-Document creation during Inventory Pick flows (when `InvtPickPutaway`, `CommitIsSuppressed`, or `PreviewMode` is set) - Subscribe to the new `OnAfterPostWhseActivityCompleted` event for deferred E-Document creation — this event fires after all posting work completes (including `PostRelatedInboundTransfer`), so the full transaction is already persisted - Migrate Subcontracting subscriber from obsoleted `OnAfterPostWhseActivHeader` to `OnAfterPostWhseActivityCompleted` **NAV dependency:** NAV master PR [242528](https://dynamicssmb2.visualstudio.com/Dynamics%20SMB/_git/NAV/pullrequest/242528) (obsoletes `OnAfterPostWhseActivHeader`, adds `OnAfterPostWhseActivityCompleted`) [AB#625588](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/625588) Fixes #7178 --------- Co-authored-by: Magnus Hartvig Grønbech <magnushar@microsoft.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: mazhelez <mazhelez@users.noreply.github.com>
Groenbech96
pushed a commit
that referenced
this pull request
Mar 18, 2026
…Pick (#7132) Regression test for bug 625438: verifies that when an Inventory Pick posting fails (lot not available on the selected bin), no Posted Sales Shipment, ILE, or E-Document is created. Also verifies the happy path where successful posting creates all expected records including the deferred E-Document via OnAfterPostWhseActivityCompleted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 task
Groenbech96
added a commit
that referenced
this pull request
Mar 19, 2026
Fix E-Document premature `Commit()` during Inventory Pick posting that causes data inconsistency (Bug 625438). When an Inventory Pick posts with an E-Document Service Flow configured, the E-Document export path executes an unconditional `Commit()` inside `OnAfterPostSalesDoc`. This commits the Sales Shipment and ILE before warehouse entries are created, causing an inventory-to-warehouse ledger mismatch if the warehouse bin check later fails. - Add `AllowCreateEDocument` guard to `OnAfterPostSalesDoc`, `OnAfterTransferOrderPostShipment`, and `OnAfterPostServiceDoc` subscribers to skip E-Document creation during Inventory Pick flows (when `InvtPickPutaway`, `CommitIsSuppressed`, or `PreviewMode` is set) - Subscribe to the new `OnAfterPostWhseActivityCompleted` event for deferred E-Document creation — this event fires after all posting work completes (including `PostRelatedInboundTransfer`), so the full transaction is already persisted - Migrate Subcontracting subscriber from obsoleted `OnAfterPostWhseActivHeader` to `OnAfterPostWhseActivityCompleted` **NAV dependency:** NAV master PR [242528](https://dynamicssmb2.visualstudio.com/Dynamics%20SMB/_git/NAV/pullrequest/242528) (obsoletes `OnAfterPostWhseActivHeader`, adds `OnAfterPostWhseActivityCompleted`) [AB#625588](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/625588) Fixes #7178 --------- Co-authored-by: Magnus Hartvig Grønbech <magnushar@microsoft.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: mazhelez <mazhelez@users.noreply.github.com>
Groenbech96
added a commit
that referenced
this pull request
Mar 19, 2026
…ng Inventory Pick posting (#7210) ## Summary Cherry-pick of 590e653 from `main` to `releases/28.x`. - Fix E-Document premature `Commit()` during Inventory Pick posting that causes data inconsistency (Bug 625438) - Add `AllowCreateEDocument` guard to skip E-Document creation during Inventory Pick flows - Subscribe to `OnAfterPostWhseActivityCompleted` for deferred E-Document creation - Migrate Subcontracting subscriber to `OnAfterPostWhseActivityCompleted` Original PR: #7132 [AB#625589](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/625589) --------- Co-authored-by: Magnus Hartvig Grønbech <magnushar@microsoft.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: mazhelez <mazhelez@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix E-Document premature
Commit()during Inventory Pick posting that causes data inconsistency (Bug 625438).Problem
When an Inventory Pick posts with an E-Document Service Flow configured, the E-Document export path executes an unconditional
Commit()insideOnAfterPostSalesDoc. This commits the Sales Shipment and ILE before warehouse entries are created, causing an inventory-to-warehouse ledger mismatch if the warehouse bin check later fails.Solution
AllowCreateEDocumentguard toOnAfterPostSalesDoc,OnAfterTransferOrderPostShipment, andOnAfterPostServiceDocsubscribers to skip E-Document creation during Inventory Pick flows (whenInvtPickPutaway,CommitIsSuppressed, orPreviewModeis set)OnAfterPostWhseActivityCompletedevent for deferred E-Document creation — this event fires after all posting work completes (includingPostRelatedInboundTransfer), so the full transaction is already persistedOnAfterPostWhseActivHeadertoOnAfterPostWhseActivityCompletedNAV dependency: NAV master PR 242528 (obsoletes
OnAfterPostWhseActivHeader, addsOnAfterPostWhseActivityCompleted)AB#625588
Fixes #7178