Preserve business filters when recommending Record.Get - #205
Open
Stefano Demiliani (demiliani) wants to merge 1 commit into
Open
Stefano Demiliani (demiliani) wants to merge 1 commit into
Stefano Demiliani (demiliani) wants to merge 1 commit into
Conversation
Stefano Demiliani (demiliani)
requested review from
Bardur Knudsen (BardurKnudsen) and
Bugsy (pchriste-microsoft-com)
as code owners
October 1, 2026 09:06
Jesper Schulz-Wedde (JesperSchulz)
approved these changes
Oct 1, 2026
Jesper Schulz-Wedde (JesperSchulz)
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 34424c390cf909a437c80558088f7ef7962da7ed. The guidance accurately reflects AL behavior: Record.Get uses the primary key and ignores ordinary record filters, while FindFirst respects them. The good samples preserve business conditions either by retaining filtered FindFirst or explicitly validating eligibility after Get; the bad sample demonstrates the filter loss. Deterministic retrieval ranks the pair correctly, and no conflict with loop/cache/blocked-master guidance was found. No merge-critical issue remains; the repository validation workflows should still be approved and allowed to run before merge.
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.
Why This Correction Is Needed
The existing performance article recommends replacing
FindFirstwithGetwhen the full primary key is known, but does not explicitly protect additional business filters. That can turn a performance recommendation into a behavior-changing correction.For example, a lookup filtered by customer number and
Blocked = blankonly accepts an unblocked customer. Replacing it withCustomer.Get(CustomerNo)does not preserve theBlockedcondition. Even leavingSetRange(Blocked, ...)beforeGetdoes not help:Getignores normal record filters.Microsoft documents this behavior in Record.Get remarks. Security filters are explicitly separate: their effect depends on Security Filter Mode and this PR does not describe them as universally bypassed.
What Changes
Getfor full-primary-key-only lookups, but require preserving additional effective business conditions, including filters established by callers or helpers.FindFirst, or explicitly enforce equivalent eligibility conditions after a successfulGetand before using the record.FindFirstis not automatically a defect just because all primary-key fields are filtered when another filter must also hold.Blockedfilter beforeGet.FindFirstand a successfulGetfollowed by an explicitBlockedcheck. Preserve the existing key-only good/bad examples.Scope And Admission Rationale
This is one concern: preserving lookup semantics when recommending a primary-key rewrite. It belongs to the Microsoft-owned performance article that already recommends that rewrite. The BC-specific filter behavior can produce an incorrect remediation or a false-positive review; it is not a generic coding-style rule or a compiler diagnostic.
The article remains universally applicable (
bc-version: [all]); the cited Get method is documented from runtime 1.0. No new domain, skill, report schema or protocol is introduced. The composition-validator change is submitted independently in #204.Validation And Limits
Passed against the knowledge worktree:
tools/Test-ReviewFixtures.ps1(218 cases; 109/330 paired articles across 20 leaf domains, including review-contract checks).github/scripts/Test-KnowledgeIndex.ps1and its delegated retrieval tests on a plain temporary copy outside OneDrive (398 articles and 683 samples round-tripped)git diff --checkEditor diagnostics found no errors in the four changed files. Python/PyYAML frontmatter validation was not run locally because no usable Python interpreter was available; it remains for CI.
These are static corpus/index/retrieval checks. The samples are demonstration-only under READ and were not compiled or executed in Business Central. No real-model evaluation was performed, and no claim is made that the new rule has already demonstrated an improvement in model accuracy.