bcquality/microsoft/knowledge/style/case-action-on-line-after-possibility.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.4 KiB

bc-version domain keywords technologies countries application-area
all
style
case
statement
formatting
possibility
action
line-break
al
w1
all

case action goes on the line after the possibility

Description

In an AL case statement, the action for each label is written on the line that follows the label, not on the same line. 'A': Letter2 := '10'; on a single line is the discouraged form; the convention is 'A': on one line and Letter2 := '10'; on the next, indented one level deeper. The exception is when the action is a begin … end block — there the begin follows the colon on the same line, consistent with the rule for then begin / else begin / do begin.

Best Practice

Each case label sits on its own line, terminated by :. The action below it is indented; multi-statement actions open with begin on the label line and close with end; on its own line.

See sample: case-action-on-line-after-possibility.good.al.

Anti Pattern

'A': Letter2 := '10'; (single-line label and action), and 'C': begin Letter2 := '12'; DoSomething(); end; (everything on one line including the block body). Both defeat per-line diff review and crowd the control flow.

See sample: case-action-on-line-after-possibility.bad.al.