Fix Patterns & Diagnosis Template
Table of contents
- Diagnosis template
- FP-01 — CalcFields not called
- FP-02 — SetLoadFields truncating data
- FP-03 — Event subscriber signature mismatch
- FP-04 — Direct assignment instead of Validate
- FP-05 — Missing IsHandled check in OnBefore event
- FP-06 — Modify(true) in bulk migration
- FP-07 — Missing indirect permission on codeunit
- FP-08 — CalcSums instead of loop accumulation
- FP-09 — FlowField in repeat..until loop
- FP-10 — OnBeforeDelete missing in tableextension
- Checklist before committing the fix
Diagnosis template
Create this file before writing any code. Name it {object-name}-diagnosis.md.
# Bug Diagnosis — {Short title}
**Date:** YYYY-MM-DD
**Severity:** Critical / High / Medium / Low
**Status:** Investigating → Diagnosed → Fixed → Verified
## Symptom
{Exact description of what the user observes. Quote the error message if any.}
**Reproducibility:** Always / Intermittent / Specific condition
## Layer and category
- **Layer:** Data / Logic / UI / Integration / Security / Configuration
- **Category:** {from symptom-map.md}
## Hypotheses
| Priority | Root cause | Probability | Evidence for/against |
|---|---|---|---|
| 1 | {cause} | HIGH | {evidence} |
| 2 | {cause} | MEDIUM | {evidence} |
| 3 | {cause} | LOW | {evidence} |
## Confirmed root cause
{Technical explanation. Quote the specific line, trigger, or condition that is wrong.}
## Proposed fix
{One paragraph description of the fix. No code yet — confirm with user first.}
## Regression risk
{What adjacent functionality could be affected by this fix? What test covers it?}
## Tests required
- **Happy path:** {scenario that was broken, now works}
- **Adjacent:** {nearest scenario that must not change}
- **Edge case:** {boundary condition most at risk}
Fix patterns by root cause category
FP-01 — CalcFields not called
Symptom: FlowField shows 0 or stale value in code but correct in BC UI.
Root cause: The BC runtime auto-calculates FlowFields on page load for display, but in AL code you must call CalcFields explicitly.
// ❌ Wrong — FlowField not calculated
Customer.Get(CustomerNo);
TotalBalance := Customer."Balance (LCY)"; // always 0
// ✅ Fix — call CalcFields before reading
Customer.SetLoadFields("Balance (LCY)");
Customer.Get(CustomerNo);
Customer.CalcFields("Balance (LCY)");
TotalBalance := Customer."Balance (LCY)";
Rule: One CalcFields call per record per code path. Never inside a repeat...until loop — call it once outside if possible, or use CalcSums for aggregations.