Fix: Gracefully skip invalid additional field values during E-Doc finalization#7296
Fix: Gracefully skip invalid additional field values during E-Doc finalization#7296ventselartur wants to merge 9 commits intomainfrom
Conversation
…l field validation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rflow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…623716-PAFinalizeFieldLength
…haseLine Instead of adding EDocument as a parameter to the public procedure ApplyAdditionalFieldsFromHistoryToPurchaseLine, retrieve it internally via EDocumentPurchaseLine."E-Document Entry No.". This reverts the signature change in the caller (EDocCreatePurchaseInvoice) as well. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@ventselartur please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
AL Documentation Audit
Documentation gaps were detected in the following apps:
- E-Document-Core-Tests: 0% documentation coverage
- E-Document-Core: 0% documentation coverage
To generate documentation, run /al-docs init or /al-docs update using GitHub Copilot CLI or Claude Code.
This review is for awareness to help keep documentation in sync with code changes. It is okay to dismiss this request.
Summary
Fixes AB#623716 — [Payables Agent] Draft could not be finalised due to field length issues.
Root Cause
ApplyAdditionalFieldsFromHistoryToPurchaseLineinEDocPurchaseHistMapping.Codeunit.alusesFieldRef.Validate()to dynamically apply "additional field" values onto Purchase Line fields. The source values are stored inText[2048]/Code[2048]fields inE-Document Line - Field, but target Purchase Line fields can be as narrow asCode[10]— causing a runtime error that halts the entire finalization. No purchase document is created even though the problematic field is a supplementary value from history, not a core field.Fix
Wrapped
FieldRef.Validate()in a[TryFunction]. On failure (length overflow, table relation failure, OnValidate trigger error, or any other validation issue), the field is skipped and a warning is logged on the e-document viaEDocumentErrorHelper.LogWarningMessage. The finalization continues and the purchase document is created. Users can review which fields were skipped in the e-document's warning messages.The
EDocumentrecord needed for warning logging is resolved internally fromEDocumentPurchaseLine."E-Document Entry No."— no changes to the public procedure signature.Key Changes
EDocPurchaseHistMapping.Codeunit.al: Added[TryFunction] TryValidateFieldValuewrappingFieldRef.Validate(). On failure, capturesGetLastErrorText()and logs a warning with field name, ID, value, and error details.EDocProcessTest.Codeunit.al: TestAdditionalFieldValueExceedingFieldLengthShouldWarnverifies that finalization succeeds, a warning (not error) is logged, and the purchase document is created despite the oversized field value.Test plan
Code[10]field (Location Code)