Skip to content

[Main] - User encounters a "record is not open" error when attaching a document to a posted sales shipment in Dynamics 365 (Base Application v28). - #10160

Open
DhavalMore88 wants to merge 3 commits into
microsoft:mainfrom
DhavalMore88:bugs/Bug-646549-Main-User-encounters-a-record-is-not-open-error-when-attaching
Open

[Main] - User encounters a "record is not open" error when attaching a document to a posted sales shipment in Dynamics 365 (Base Application v28).#10160
DhavalMore88 wants to merge 3 commits into
microsoft:mainfrom
DhavalMore88:bugs/Bug-646549-Main-User-encounters-a-record-is-not-open-error-when-attaching

Conversation

@DhavalMore88

@DhavalMore88 DhavalMore88 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Bug 646549: [master] [All-E] [SME][SaaS] User encounters a "record is not open" error when attaching a document to a posted sales shipment in Dynamics 365 (Base Application v28).

AB#646549

Issue: When a user uploads a file from the Documents FactBox ("Doc. Attachment List Factbox", Page 1178) on a Posted Sales Shipment, the upload fails with the runtime error "The record is not open." The same happens on Posted Return Receipt, while the identical action works correctly on Sales Order, Purchase Order and Posted Sales Invoice. The AL call stack points to Table 1173 "Document Attachment".InsertAttachment / SaveAttachmentFromStream.

Cause: The GetRefTable procedure in DocumentAttachmentMgmt.Codeunit.al (Codeunit 1173) has a case DocumentAttachment."Table ID" statement with no branch for Database::"Sales Shipment Header" (110) or Database::"Return Receipt Header" (6661), even though both tables are already registered in TableHasNumberFieldPrimayKey. Because no branch matches, RecRef.Open() is never called, GetRefTable returns false, and the FactBox's AttachmentsUpload action ignored that result and passed the unopened RecordRef on to DocumentAttachment.SaveAttachment(files, RecRef), where RecRef.Find() in InsertAttachment throws "The record is not open."

Solution: Added the missing Database::"Sales Shipment Header" and Database::"Return Receipt Header" cases to GetRefTable, each opening the RecordRef on its table and calling GetTable when the posted document is found — matching the existing pattern used for Sales Invoice Header and Sales Cr.Memo Header. Additionally hardened all three GetRefTable call sites in DocAttachmentListFactbox.Page.al (Upload files, Show details, Attach from email) to raise a clear error when the source record still cannot be resolved after the OnAfterGetRecRefFail event, instead of letting an unopened RecordRef reach the platform and surface the cryptic message for any other unmapped table.

@github-actions github-actions Bot added From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item labels Aug 12, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 12, 2026
@DhavalMore88
DhavalMore88 marked this pull request as ready for review August 13, 2026 12:31
@DhavalMore88
DhavalMore88 requested a review from a team August 13, 2026 12:31
Comment thread src/Layers/W1/Tests/Misc/DocumentAttachmentTests.Codeunit.al
@DhavalMore88 DhavalMore88 added the SCM GitHub request for SCM area label Aug 13, 2026
@github-actions github-actions Bot removed the SCM GitHub request for SCM area label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant