Repository navigation
knowledge(performance): add trigger-only fields to API pages with AddLoadFields - #253
Open
Kilian Seizinger (pri-kise) wants to merge 1 commit into
Open
Kilian Seizinger (pri-kise) wants to merge 1 commit into
Kilian Seizinger (pri-kise) wants to merge 1 commit into
Conversation
…LoadFields API/OData pages load only fields bound to page controls. Fields that only trigger code reads (typically OnAfterGetRecord filling a variable-bound API field) are JIT-loaded per row. Recommend Rec.AddLoadFields in OnOpenPage, as Microsoft's ExpenseAgent API pages do, and flag SetLoadFields there because it replaces the platform's layout-based selection.
Kilian Seizinger (pri-kise)
marked this pull request as ready for review
October 28, 2026 10:51
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.
Mistake prevented
API and OData pages load only the fields bound to page controls (partial records applied by the platform). A common API pattern binds an API field to a global variable and fills it from
RecinOnAfterGetRecord, for example to convert a currency code or combine address fields. TheRecfields read there are not bound to any control. Each row's first access then triggers a JIT load (an implicitGet), and a concurrent change can make that load fail with "Inconsistent read of field(s)" or "JIT loading of field(s) ... failed".The compiler and analyzers don't flag this, and the page returns correct data, so a reviewer or an authoring agent misses it. The cost only shows in telemetry and SQL load. We hit exactly this in partner API pages: telemetry reported "JIT loading of field(s): 'Post Code' failed for table: 'Contact'" until
Rec.AddLoadFieldswas added inOnOpenPage.The article also flags the tempting wrong fix:
Rec.SetLoadFieldsinOnOpenPage. It replaces the platform's layout-based selection, so layout fields that aren't listed become JIT loads.Evidence
AddLoadFieldsfromOnOpenPageon OData pages.Versions
bc-version: [17..]: partial records andAddLoadFieldsarrived in BC 2020 release wave 2.Domain
performance, next to the report counterpartaddloadfields-in-report-onpredataitem.md, which covers the same mechanic for report dataitems.Checks
tools/Build-KnowledgeIndex.ps1: the article parses and is indexed.tools/Test-ReviewFixtures.ps1: passed.tools/Test-ReviewContract.ps1: passed.validate_frontmatter.pywas not run locally (no Python on this machine); CI will run it.