Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

Document attachment operations on E-Document pages fail with "The record is not open" because the RecordRef is opened to the table but never initialized with a valid record.

Changes

SubPageLink missing Table ID (EDocument.Page.al, EDocumentPurchaseDraft.Page.al)

  • Added "Table ID" = const(Database::"E-Document") to Doc. Attachment List Factbox SubPageLink, matching pattern in OutboundEDocuments.Page.al and InboundEDocuments.Page.al

Incorrect primary key type in EDocument.Get (EDocAttachmentProcessor.Codeunit.al)

  • OnAfterGetRefTableForEDocs was calling EDocument.Get(DocumentAttachment."No.") with a text value, but E-Document's PK is Entry No (Integer)
  • Fixed to convert text to integer before Get, and only open RecordRef when record exists:
// Before: Opens RecordRef unconditionally, Get fails silently
RecRef.Open(Database::"E-Document");
if EDocument.Get(DocumentAttachment."No.") then
    RecRef.GetTable(EDocument);

// After: Only opens RecordRef when valid record found
if Evaluate(EntryNo, DocumentAttachment."No.") then
    if EDocument.Get(EntryNo) then begin
        RecRef.Open(Database::"E-Document");
        RecRef.GetTable(EDocument);
    end;

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Groenbech96 <17690329+Groenbech96@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug for 'The record is not open' error Fix missing Table ID in SubPageLink for E-Document attachment factbox Jan 27, 2026
Copilot AI requested a review from Groenbech96 January 27, 2026 11:51
Co-authored-by: Groenbech96 <17690329+Groenbech96@users.noreply.github.com>
Copilot AI changed the title Fix missing Table ID in SubPageLink for E-Document attachment factbox Fix RecordRef not open error for E-Document attachments Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants