Conversation
…n Work Center or Item is deleted
SetCurrentKey("Work Center No.") and SetCurrentKey("Item No.") in SubcWorkCenterExtension and
SubcItemExtension failed at runtime because neither field was the first field of any key on
the SubcontractorPrice table. This caused a runtime error whenever a Work Center or Item
with associated Subcontractor Prices was deleted, preventing the deletion from completing.
Added secondary keys Key03 (Work Center No.) and Key04 (Item No.) to the SubcontractorPrice
table so the SetCurrentKey calls resolve correctly and deletion cascades as intended.
Added tests DeleteWorkCenterWithPricesDeletesRelatedPrices and
DeleteItemWithPricesDeletesRelatedPrices in SubcSubcontractingTest to cover both scenarios.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…logic Move the SetCurrentKey/SetRange/DeleteAll pattern out of the three separate extension codeunits into dedicated procedures on the SubcontractorPrice table, eliminating duplication and making future maintenance a single-point change. - SubcontractorPrice.Table.al: add DeletePricesForVendor, DeletePricesForWorkCenter, DeletePricesForItem - SubcVendorExtension, SubcWorkCenterExtension, SubcItemExtension: each now calls the corresponding table procedure instead of repeating the same pattern inline Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
AL Documentation Audit
Documentation gaps were detected in the following apps:
- Subcontracting-Test: 0% documentation coverage
- Subcontracting: 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.
The three new centralized deletion procedures (DeletePricesForVendor, DeletePricesForWorkCenter, DeletePricesForItem) should not be part of the public API surface — mark them internal so they are only callable within the Subcontracting app. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
AnalysisCorrectness:
Side Effects:
Risk Assessment: Low.
Test Coverage:
Recommendation: Accept with SuggestionsThe fix is correct, low-risk, and well-localized. It satisfies the DRY intent of the linked work item and additionally hardens two
|
alexei-dobriansky
approved these changes
Apr 28, 2026
AleksandricMarko
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SetCurrentKey("Work Center No.")inSubcWorkCenterExtension.Codeunit.alandSetCurrentKey("Item No.")inSubcItemExtension.Codeunit.alfailed at runtime because neither field was the first field of any existing key on theSubcontractorPricetable.Key03 ("Work Center No.")andKey04 ("Item No.")toSubcontractorPrice.Table.also theSetCurrentKeycalls resolve correctly and cascaded deletion works as intended.Root cause
The
SubcVendorExtensioncorrectly callsSetCurrentKey("Vendor No.")because"Vendor No."is the first field of the clustered PK. The other two extensions used fields that are not the first field of any key:"Vendor No.""Work Center No.""Item No."Fix
Added two secondary keys to
SubcontractorPrice.Table.al:key(Key03; "Work Center No.")key(Key04; "Item No.")Tests added
DeleteWorkCenterWithPricesDeletesRelatedPrices(codeunit 139989) — creates a work center with multiple subcontractor prices, deletes the work center, asserts all prices are deletedDeleteItemWithPricesDeletesRelatedPrices(codeunit 139989) — creates an item with multiple subcontractor prices, deletes the item, asserts all prices are deletedFixes AB#620643
🤖 Generated with Claude Code