[Master]-Vendor Order No. exceeds 20-character limit causing error in Intercompany Purchase Invoice#9204
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a runtime error when opening an intercompany-created Purchase Invoice if "Vendor Order No." exceeds the 20-character limit of "IC Reference Document No." used in a duplicate-document lookup. The change is applied consistently across W1 and localized BaseApp layers, and is validated with new regression tests.
Changes:
- Prevents string-length overflow by guarding the
SetRange("IC Reference Document No.", Rec."Vendor Order No.")logic with aStrLen(...) <= MaxStrLen(...)check. - Adds automated test coverage to ensure IC-created Purchase Invoices open successfully and retain long "Vendor Order No." values.
- Mirrors the page fix and the test in all layers that contain the relevant objects.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Layers/W1/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Adds length guard to avoid overflow when filtering by IC Reference Document No. |
| src/Layers/RU/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for RU layer Purchase Invoice page. |
| src/Layers/NO/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for NO layer Purchase Invoice page. |
| src/Layers/NL/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for NL layer Purchase Invoice page. |
| src/Layers/NA/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for NA layer Purchase Invoice page. |
| src/Layers/IT/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for IT layer Purchase Invoice page. |
| src/Layers/FI/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for FI layer Purchase Invoice page. |
| src/Layers/ES/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for ES layer Purchase Invoice page. |
| src/Layers/CH/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for CH layer Purchase Invoice page. |
| src/Layers/BE/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for BE layer Purchase Invoice page. |
| src/Layers/APAC/BaseApp/Purchases/Document/PurchaseInvoice.Page.al | Same length guard fix for APAC layer Purchase Invoice page. |
| src/Layers/W1/Tests/ERM/ERMIntercompanyIII.Codeunit.al | Adds regression test covering opening IC-created invoice with long Vendor Order No. |
| src/Layers/NL/Tests/ERM/ERMIntercompanyIII.Codeunit.al | Same regression test for NL test layer. |
| src/Layers/CZ/Tests/ERM/ERMIntercompanyIII.Codeunit.al | Same regression test for CZ test layer. |
| src/Layers/CH/Tests/ERM/ERMIntercompanyIII.Codeunit.al | Same regression test for CH test layer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot PR ReviewIteration 3 · Outcome: completed
Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
Agentic PR Review - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis PR fixes opening an IC-created Purchase Invoice when Vendor Order No. is longer than the 20-character IC Reference Document No. field used for duplicate lookup. The fix does not truncate the value and does not extend the schema field; it skips that lookup when the value cannot fit, while leaving the later original-order warning path in place. That is the safer choice here. Truncating could match the wrong document, and extending IC Reference Document No. would be a schema compatibility change. The added regression test opens the Purchase Invoice page on an IC-created invoice with a 35-character Vendor Order No. and verifies the value is retained. SuggestionsS1 - Remove the added UTF-8 BOMs Risk assessment and necessityRisk: Functional risk is low. The change only guards a duplicate-document lookup that could not safely run for values longer than the target Code[20] field. No data is truncated, and no field length is changed. The repeated page changes are consistent across the touched copies; the only non-functional risk is the added BOM in two files. Necessity: The work item describes a real customer path where reopening the IC purchase invoice fails with a string-length error and no workaround. The fix is needed, narrow, and covered by a regression test for the affected page path.
|
|
@neeleshsinghal please clean the localizations |
…-Bug-641567-Vendor-Order-No-more-than-20-words-Intercompany-Purchase-Inv
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agentic PR Review - Round 2Recommendation: AcceptWhat this PR doesSince round 1, the PR merged main and then added two non-merge commits. Those two commits remove the added UTF-8 BOMs from the NO and IT Status of previous suggestions
New observations (commits since round 1)None - changes only addressed the previous suggestion. Risk assessment and necessityRisk: The round-2 non-merge changes are non-functional. They only remove file BOM bytes from the NO and IT purchase invoice page files, so they do not change runtime behavior. Necessity: The cleanup is needed to keep the PR diff limited to the intended Business Central fix. The original bug scenario remains valid and the functional scope remains narrow.
|
Fixes AB#641567
Workitem :- Bug 641567: [All-e]Master][SaaS] Vendor Order No. exceeds 20-character limit causing error in Intercompany Purchase Invoice