Skip to content

Conversation

@Groenbech96
Copy link
Contributor

@Groenbech96 Groenbech96 commented Jan 17, 2026

Summary

Overview

The Link to Existing Document action allows users to associate an incoming e-document with a purchase document that already exists in Business Central, rather than creating a new document. This is useful when:

  • The purchase document was created manually before the e-document arrived
  • You want to attach the e-document as supporting documentation to an existing transaction
  • You need to correct a previous linking by choosing a different document

Prerequisites

Before you can use the Link to Existing Document action:

  1. The e-document must have a vendor number assigned in the draft
  2. The vendor must have an IC Partner Code configured on the vendor card

How to link an e-document to an existing document

  1. Open the E-Document Purchase Draft page
  2. Ensure a vendor is assigned to the e-document
  3. Select the Link to Existing Document action from the Process menu
  4. A list of purchase documents opens, pre-filtered by:
    • The vendor from the e-document
    • The total amount (Amount Incl. VAT) from the e-document
  5. Select the document you want to link to
  6. Confirm the linking action when prompted

What happens after linking

When you link an e-document to an existing purchase document:

Field | Value -- | -- E-Document Link (on Purchase Document) | Set to the e-document's system ID Doc. Amount Incl. VAT | Transferred from e-document total Doc. Amount VAT | Transferred from e-document VAT total Created from E-Document | Set to No (the document existed before linking) E-Document Status | Changed to Processed

Important: No new purchase document is created when linking to an existing document.


Relinking to a different document

If the e-document is already processed (linked to a document) and you want to link it to a different document:

  1. When you select Link to Existing Document, a warning message appears:

    "This e-document is already linked to a document. Linking to [Document Type] [Document No.] will unlink the currently linked document. If it was created from this e-document, it will be deleted. Do you want to continue?"

  2. If you proceed:

    • If the previously linked document was created from this e-document: The document is deleted
    • If the previously linked document was NOT created from this e-document: The document is unlinked only (E-Document Link field is cleared, but the document remains)
  3. The newly selected document becomes linked to the e-document

Work Item(s)

Fixes AB#608917

@Groenbech96 Groenbech96 requested a review from a team as a code owner January 17, 2026 11:44
@github-actions github-actions bot added the AL: Apps (W1) Add-on apps for W1 label Jan 17, 2026
@Groenbech96 Groenbech96 changed the title Clean up page and add action E-Document - Clean up and add link ability. Jan 17, 2026
@github-actions github-actions bot added this to the Version 28.0 milestone Jan 17, 2026
@Groenbech96 Groenbech96 changed the title E-Document - Clean up and add link ability. E-Document - Add link action. Jan 21, 2026
Magnus Hartvig Grønbech added 2 commits January 21, 2026 14:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds functionality to link e-documents to existing purchase documents instead of always creating new ones. It introduces a "Link to existing document" action on the draft page and tracks whether documents were created from e-documents or linked to existing ones, preventing deletion of manually created documents.

Changes:

  • Added "Link to existing document" action to the E-Document Purchase Draft page with filtering by vendor and amount
  • Introduced "Created from E-Document" field to track document origin and conditionally delete only auto-created documents
  • Extended E-Doc. Import Parameters with "Existing Doc. RecordId" field to support linking workflow

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
EDocumentPurchaseDraft.Page.al Added LinkToExistingDocument action and DoLinkToExistingDocument procedure to enable manual linking
EDocCreatePurchaseInvoice.Codeunit.al Modified ApplyDraftToBC to support linking to existing documents; updated RevertDraftActions to preserve manually created documents
EDocImportParameters.Table.al Added "Existing Doc. RecordId" field to pass selected document through processing pipeline
EDocumentProcessing.Codeunit.al Added helper procedures: GetPurchaseDocTypeFilter, LinkToExistingPurchaseDocument, ErrorIfNotAllowedToLinkToExistingDoc, and OpenPurchaseDocumentList
EDocPurchaseHeader.TableExt.al Added "Created from E-Document" boolean field with proper copyright header
EDocLinkToExistingTest.Codeunit.al Comprehensive test coverage for linking functionality including validation, document selection, and post-link behavior scenarios
EDocProcessTest.Codeunit.al Added test for GetPurchaseDocTypeFilter function
LibraryEDocument.Codeunit.al Enhanced CreateInboundEDocument to set Direction and Service fields for proper test setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…odeunit.al

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ventselartur
ventselartur previously approved these changes Jan 21, 2026
mynjj
mynjj previously approved these changes Jan 22, 2026
@Groenbech96 Groenbech96 dismissed stale reviews from mynjj and ventselartur via e8963d1 January 22, 2026 09:34
mynjj
mynjj previously approved these changes Jan 22, 2026
ventselartur
ventselartur previously approved these changes Jan 22, 2026
@Groenbech96 Groenbech96 enabled auto-merge (squash) January 22, 2026 10:22
@Groenbech96 Groenbech96 dismissed stale reviews from ventselartur and mynjj via 3516af3 January 22, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants