bcquality/microsoft/knowledge/style/temporary-variable-temp-prefix.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
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 Temp — TempJobWIPBuffer, 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.