bcquality/microsoft/knowledge/style/temporary-variable-temp-prefix.md
Jesper Schulz-Wedde e81632b4be Complete AL review knowledge readiness
Fill telemetry and Query coverage, strengthen thin review domains, correct audited content defects, and add deterministic cheap-model evaluation and reference-integrity safeguards.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9825b012-e653-496a-9310-c1f4b6f8ac27
2026-07-15 07:19:15 +02:00

1.5 KiB

bc-version domain keywords technologies countries application-area
all
style
temporary
temp
prefix
record-variable
naming
al
w1
all

Prefix temporary record variables with Temp

Description

A Record variable declared with the temporary modifier behaves nothing like a normal record variable: it never touches the database, holds rows only for the lifetime of the variable, and is not visible to filters or queries on the underlying table. The BC convention is to make that difference visible at every call site by prefixing the variable name with TempTempJobWIPBuffer, TempSalesLine, TempIntegerBuffer. The convention is load-bearing for code review: when a reader sees SalesLine.Insert(), they expect a database write; when they see TempSalesLine.Insert(), they know it is an in-memory buffer.

Best Practice

Every local or global variable of type Record X temporary must start with Temp. Ordinary procedure parameters follow the same convention. Event publisher parameters are owned by the events-domain rule prefix-temporary-record-event-parameters-with-temp.md; the style leaf must not emit a second finding for the same event parameter.

See sample: temporary-variable-temp-prefix.good.al.

Anti Pattern

WIPBuffer: Record "Job WIP Buffer" temporary; as a local, global, or ordinary procedure parameter reads at the call site as if it were a database operation. Exclude event publisher parameters here so the events leaf remains their single owner.

See sample: temporary-variable-temp-prefix.bad.al.