Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.

[Enforced Digital Vouchers] - Attaching E-Documents when using Digital Vouchers - #29793

Closed
Grasiele Matuleviciute (GMatuleviciute) wants to merge 16 commits into
microsoft:mainfrom
GMatuleviciute:dev/aan/digitalvoucher
Closed

Grasiele Matuleviciute (GMatuleviciute) wants to merge 16 commits into
microsoft:mainfrom
GMatuleviciute:dev/aan/digitalvoucher

Conversation

@GMatuleviciute

@GMatuleviciute Grasiele Matuleviciute (GMatuleviciute) commented Mar 5, 2026 •

Copy link
Copy Markdown

This pull request does not have a related issue as it's part of the delivery for development agreed directly with Aleksandar Totovic (@altotovi) Magnus Hartvig Grønbech (@Groenbech96)

Implementation

With this update enhanced automation for Digital Vouchers in sales and purchase document posting. When enabled, the system will automatically generate and attach E-Documents and related files to posted documents, streamlining document management and compliance.

Functional Changes

  1. New Check Type Option
  • The Check Type field in the Digital Voucher Entry Setup table has been extended to include a new option: E-Document.
  • E-Document option is only valid when the Entry Type is set to Sales Document or Purchase Document.
  • The E-Document check type can only be selected when Generate Automatically is set to TRUE.
  1. Automated Document Attachment on Posting

When posting sales or purchase documents, if setup is set to use E-Documents the system will attach related E-Document files to the Incoming Document Files of the posted sales/purchase document.

Impact

Reduces manual effort in attaching compliance documents.
Ensures all relevant files are consistently linked to posted documents.

Important

This Pull request related with microsoft/BCApps#7006

Fixes #

Fixes AB#639562

Introduces E-Document as a new check type for digital vouchers, enforcing automatic generation and linking for purchase documents. Updates UI logic to ensure consistent behavior and validation. Extends data structures and event handling to support E-Document attachment and integration with related processes.

Enables more robust compliance with regulatory requirements for electronic document management.
Adds feature flag and setup validations before attaching digital vouchers to documents, ensuring attachments only occur when the functionality is enabled and properly configured. Expands handling for purchase credit memos and improves type checks for both sales and purchase documents.
Streamlines digital voucher validation by generalizing E-Document attachment to support more document types and rely on record references rather than hardcoded field access or document types. Improves maintainability and feature extensibility by extracting document details via a dedicated method and refining permission set object ordering. Enhances code clarity and robustness in preparation for feature expansion.
Introduces comprehensive automated tests covering E-Document attachment behavior for sales and purchase documents, ensuring correct enforcement and attachment logic. Updates dependency declarations for better test isolation, removes unused variables, and improves error checking and file name handling for E-Document processing. Enhances reliability and maintainability of digital voucher and E-Document integration.
…herEntrySetup.Table.al

Co-authored-by: Grasiele Matuleviciute <131970463+GMatuleviciute@users.noreply.github.com>
…herEntrySetup.Table.al

Co-authored-by: Grasiele Matuleviciute <131970463+GMatuleviciute@users.noreply.github.com>
Refactors E-Document file attachment for purchase documents by relocating the logic from the check codeunit to the main implementation codeunit, improving code structure and responsibility separation. Updates test object ranges, enhances test reliability, and adjusts error handling to use labels for better localization. Clarifies and simplifies validation around E-Document requirements and streamlines page variable initialization. Improves maintainability and prepares for future extensibility.
@github-actions

github-actions Bot commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link.

Comment thread Apps/W1/EnforcedDigitalVouchers/test/src/EDocAttachmentTests.Codeunit.al Outdated
Improves observability by logging errors via feature telemetry when e-document attachment operations fail, including XML extraction from PDFs and incoming document imports. This helps diagnose issues in production without relying solely on user-reported errors.

Refactors a purchase document test helper to separate the case where no e-document link is needed, removing an unnecessary guard condition and simplifying the overload that requires an e-document record.

Also includes minor code style normalizations (variable reordering, lowercase `error()` calls) for consistency.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comments resolved

Comment thread Apps/W1/EnforcedDigitalVouchers/test/src/EDocAttachmentTests.Codeunit.al Outdated
Comment thread Apps/W1/EnforcedDigitalVouchers/test/app.json Outdated
Comment thread Apps/W1/EnforcedDigitalVouchers/app/app.json Outdated
ventselartur and others added 2 commits March 26, 2026 11:55
Replaces dynamic error text and call stack capture in telemetry logging with static, descriptive messages to avoid exposing potentially sensitive runtime details in telemetry.

Reorders permission set entries to group tables, pages, and codeunits together for better readability and consistency.

Also adds missing newlines at end of JSON and table files to follow standard file formatting conventions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comments resolved

Comment thread Apps/W1/EnforcedDigitalVouchers/app/app.json Outdated
Comment thread Apps/W1/EnforcedDigitalVouchers/test/app.json Outdated
Jesper Schulz-Wedde (JesperSchulz) pushed a commit to microsoft/BCApps that referenced this pull request Apr 29, 2026
…tal Vouchers (#7006)

This pull request does not have a related issue as it's part of the
delivery for development agreed directly with @altotovi @Groenbech96

**Implementation**

These integration events are required for the Enforced Digital Vouchers
app to subscribe to E-Document processing and attach digital voucher
records at the correct points in the document lifecycle.

**Events added**

OnExportEDocumentAfterCreateEDocument in EDocExport.Codeunit.al — Raised
after the e-document content has been generated and the success status
determined, but before the service status is logged. This placement
allows the Digital Vouchers subscriber to access the finalized document
blob (TempBlob) and the mapped source document records, which are needed
to create and associate a digital voucher with the exported e-document.

OnAfterUpdateToPostedPurchaseEDocument in
EDocumentSubscribers.Codeunit.al — Raised after a received purchase
e-document is updated to its posted state (document record ID, document
number, type, and status are all set). This placement allows the Digital
Vouchers subscriber to link the digital voucher to the final posted
purchase document, since the posted document number and record ID are
only available at this point.

> [!IMPORTANT]
> This Pull request related with
microsoft/ALAppExtensions#29793

Fixes
[AB#580350](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/580350)

---------

Co-authored-by: Andrius Andrulevicius <andrius.andrulevicius@companial.com>
@JesperSchulz Jesper Schulz-Wedde (JesperSchulz) added linked Issue is linked to a Azure Boards work item and removed linked Issue is linked to a Azure Boards work item labels Jun 18, 2026
@JesperSchulz Jesper Schulz-Wedde (JesperSchulz) added the processing-PR The PR is currently being reviewed label Jun 18, 2026
@JesperSchulz

Copy link
Copy Markdown
Contributor

Creating an ADO PR.

@github-actions

Copy link
Copy Markdown
Contributor

Processing this PR. The branch is now locked 🔒 Please don't push updates unless otherwise agreed.

@JesperSchulz

Copy link
Copy Markdown
Contributor

Compilation fails with:
App\Apps\W1\EnforcedDigitalVouchers\TempSource\app\src\Implementation\DigitalVoucherImpl.Codeunit.al(890,54): error AL0161: 'Codeunit Microsoft.eServices.EDocument."E-Document Subscribers"' is inaccessible due to its protection level

@GMatuleviciute

Grasiele Matuleviciute (GMatuleviciute) commented Jun 19, 2026 •

Copy link
Copy Markdown
Author

Compilation fails with: App\Apps\W1\EnforcedDigitalVouchers\TempSource\app\src\Implementation\DigitalVoucherImpl.Codeunit.al(890,54): error AL0161: 'Codeunit Microsoft.eServices.EDocument."E-Document Subscribers"' is inaccessible due to its protection level

Jesper Schulz-Wedde (@JesperSchulz) Created related PR in BCApps repos, to fix compilation issue microsoft/BCApps#8677

@JesperSchulz

Copy link
Copy Markdown
Contributor

Let's close this PR and re-open it on https://github.com/microsoft/BCApps/ once repo migration is complete next Monday. You might even combine it with your other PR on BCApps.
I'm closing down this repo for code contributions effective immediately.

@GMatuleviciute

Copy link
Copy Markdown
Author

Jesper Schulz-Wedde (@JesperSchulz) ventselartur changes are migrated to BCApps repo and merged together with access issue solution.
microsoft/BCApps#9208

pull Bot pushed a commit to Mattlk13/BCApps that referenced this pull request Aug 11, 2026
… Vouchers (microsoft#9208)

Original PR: microsoft/ALAppExtensions#29793
(closed due to migration)
This pull request does not have a related issue as it's part of the
delivery for development agreed directly with @altotovi @Groenbech96
@ventselartur

**Implementation**

With this update enhanced automation for Digital Vouchers in sales and
purchase document posting. When enabled, the system will automatically
generate and attach E-Documents and related files to posted documents,
streamlining document management and compliance.

**Functional Changes**

1. New Check Type Option

- The Check Type field in the Digital Voucher Entry Setup table has been
extended to include a new option: E-Document.
- E-Document option is only valid when the Entry Type is set to Sales
Document or Purchase Document.
- The E-Document check type can only be selected when Generate
Automatically is set to TRUE.

2. Automated Document Attachment on Posting

When posting sales or purchase documents, if setup is set to use
E-Documents the system will attach related E-Document files to the
Incoming Document Files of the posted sales/purchase document.

**Impact**

Reduces manual effort in attaching compliance documents.
Ensures all relevant files are consistently linked to posted documents.

> [!IMPORTANT]
> This Pull request related with
microsoft#7006

Fixes #

Fixes
[AB#639562](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/639562)

---------

Co-authored-by: Andrius Andrulevičius <andrius.andrulevicius@companial.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Integration GitHub request for Integration area linked Issue is linked to a Azure Boards work item processing-PR The PR is currently being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants