bcquality/microsoft/knowledge/performance/avoid-redundant-get-when-record-already-loaded.md
Jesper Schulz-Wedde 2b5550c346
Some checks failed
Validate knowledge index / validate-index (push) Has been cancelled
Validate AL review fixtures / validate-review-fixtures (push) Has been cancelled
Validate frontmatter and structure / validate (push) Has been cancelled
Improve partner onboarding and documentation navigation (#174)
Lead with a complete plugin quick start and add task-oriented usage, troubleshooting, customization, and contribution guides. Preserve the broader plugin framing, correct conflicting contract guidance, support Agents folder reviews, and align repository validation. Convert existing sample references to clickable links without changing knowledge rules.

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-09 17:31:03 +02:00

1.6 KiB

bc-version domain keywords technologies countries application-area
all
performance
get
onaftergetrecord
redundant
page-trigger
rec
already-loaded
al
w1
all

Do not Get the record the page already loaded

Description

A list or card page's OnAfterGetRecord trigger fires because the platform has already fetched a row into Rec. Calling Get for that same row inside the trigger repeats the read the platform just did. Per the upstream guidance, this is "redundant — record already fetched by page runtime"; the correction is "use Rec directly — already loaded." The waste compounds on list pages, where the trigger runs once per row displayed.

Best Practice

Inside page triggers — OnAfterGetRecord, OnAfterGetCurrRecord, validation triggers — read from Rec (or the trigger's record parameter). The platform exposes the freshly loaded record there for exactly this purpose. Reach for Get only when the trigger needs a different record than the one being displayed.

See sample: avoid-redundant-get-when-record-already-loaded.good.al.

Anti Pattern

AssemblyLineRec.Get("Document Type", "Document No.", "Line No."); at the top of OnAfterGetRecord, when the trigger is on the Assembly Line page itself and Rec already holds that row. The pattern often appears when a helper that expects a record parameter is invoked from a page trigger and the author writes a Get to "freshen" Rec rather than passing Rec through.

See sample: avoid-redundant-get-when-record-already-loaded.bad.al.