mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-06 23:26:55 +01:00
Normalisering af alle 39 custom knowledge-filer til READ-kontraktens skema (validate_frontmatter.py + Test-KnowledgeIndex.ps1 begge groenne): - R01/R02: 28 filer manglede frontmatter eller brugte aeldre skemaer (title/category/severity/rule-id m.fl.) - alle har nu praecis de 6 kraevede noegler; keywords haandskrevet pr. fil da de driver worklist-selektionen i INDEX/knowledge-index - R09: manglende Description-sektion - regel-agtige foersteoverskrifter (Core Rule/Rule/Regel/Core Principle) omdoebt, eller sektion indsat efter titlen hvor intro-tekst fandtes - R10: fenced code blocks konverteret til 4-space indrykkede blokke i alle filer (indhold uaendret) - R11: 4 filer over 100 linjer fortaettet redaktionelt uden semantisk tab (ai-eval-scores 143->100, git-lifecycle 121->97, permission-sets 113->99, test-feature-scenario-tags 105->91) - R05: AL0197->al0197, add_repo->add-repo; keyword-lister trimmet til maks 10 Ingen regler er fjernet eller aendret i betydning - kun form. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
48 lines
1.9 KiB
Markdown
48 lines
1.9 KiB
Markdown
---
|
|
bc-version: [all]
|
|
domain: mcp
|
|
keywords: [api-page, derived-fields, exposure, odata]
|
|
technologies: [al]
|
|
countries: [w1]
|
|
application-area: [all]
|
|
---
|
|
# CURABIS MCP: Stored Derived Fields Must Be Recalculated in OnAfterGetRecord
|
|
|
|
## Description
|
|
|
|
A stored field whose value is derived from other fields via `OnValidate` triggers can be stale. When the source data changes (e.g., new time entries posted), the stored derived field is not updated automatically — it only recalculates when a specific trigger fires. Exposing such a field directly via an API page returns a value that may be hours, days, or weeks out of date.
|
|
|
|
## Pattern to Avoid
|
|
|
|
// WRONG: Exposes the stored snapshot — may be stale
|
|
field(timeLeft; Rec."Time left") { }
|
|
|
|
`"Time left"` is recalculated only when `"Estimated time"` is validated. If new time entries are posted, the stored value does not update.
|
|
|
|
## Correct Pattern
|
|
|
|
Recalculate in `OnAfterGetRecord` using a page variable:
|
|
|
|
trigger OnAfterGetRecord()
|
|
begin
|
|
Rec.CalcFields("Elapsed time (Chargeable)");
|
|
TimeLeftCalc := Rec."Estimated time" - Rec."Elapsed time (Chargeable)";
|
|
end;
|
|
|
|
var
|
|
TimeLeftCalc: Decimal;
|
|
|
|
// In layout:
|
|
field(timeLeft; TimeLeftCalc) { } // live value
|
|
field(elapsedTime; Rec."Elapsed time (Chargeable)") { } // source FlowField
|
|
|
|
## Requirements
|
|
|
|
- Identify stored fields whose value is computed from other fields via triggers
|
|
- Do not expose them directly in API pages
|
|
- Recalculate from the authoritative source (FlowField or live query) in `OnAfterGetRecord`
|
|
- Expose both the recalculated result and the source FlowField so the consumer can verify
|
|
|
|
## Verification
|
|
|
|
Inspect the source table for any field with `FieldClass = Normal` whose value is set inside an `OnValidate` trigger on another field. If that field is exposed on an API page, verify it is recalculated in `OnAfterGetRecord` rather than read from `Rec` directly.
|