Reset and empty SetLoadFields restore a full-row load
SetLoadFields(...) sticks to the record variable until something clears it. Reset() "changes fields select for loading back to all", and SetLoadFields() with no arguments does the same. A later FindSet or Get then materializes every normal field.
- microsoftlayer
- performancedomain
- 2examples
- 2pull requests
Rule on GitHub · microsoft layer · performance · BC all · tier official · derived
Contributions welcome — open a PR to refine or extend this article.
Description
SetLoadFields(...) sticks to the record variable until something clears it. Reset() “changes fields select for loading back to all”, and SetLoadFields() with no arguments does the same. A later FindSet or Get then materializes every normal field. Agents often place SetLoadFields first, then Reset to apply new filters, and assume the partial selection survives. It does not.
Best Practice
Call Reset (or empty SetLoadFields()) first when the variable must be reused, then call SetLoadFields with the fields the next read actually uses, then apply filters and read. After Reset, a new SetLoadFields is required; the previous list is gone.
See sample: reset-clears-partial-record-selection.good.al.
Anti Pattern
SetLoadFields(...) followed by Reset() (or by parameterless SetLoadFields()) and then FindSet without restoring the load list. The filters look correct; the SQL still selects every column.
See sample: reset-clears-partial-record-selection.bad.al.
Examples
- Good: reset-clears-partial-record-selection.good.al
- Bad: reset-clears-partial-record-selection.bad.al
Changed by
- #174 Make BCQuality documentation easier for partners to get started, 2026-09-09
- #153 Promote knowledge for Microsoft-owned review skills, 2026-09-03
From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).