diff --git a/content/docs/analyzers/PlatformCop/PC0029.md b/content/docs/analyzers/PlatformCop/PC0029.md index eec9d34..9bc4709 100644 --- a/content/docs/analyzers/PlatformCop/PC0029.md +++ b/content/docs/analyzers/PlatformCop/PC0029.md @@ -12,7 +12,9 @@ linkTitle = 'PC0029' When a new record needs a GUID primary key, the natural reach is `CreateGuid()`. Random GUIDs scatter values across the SQL index B-tree, causing page splits on every insert. At scale — bulk imports, high-throughput journal posting — this fragmentation degrades insert, read, and update performance by 20–40%. -This rule tracks the flow of `CreateGuid()` values through variable assignments and procedure calls (within the same module) to determine whether the generated GUID ultimately lands in a key field. Replace `CreateGuid()` with `Guid.CreateSequentialGuid()`, which produces partially-sequential values that keep index inserts append-only. +This rule tracks the flow of `CreateGuid()` values through variable assignments (local and object-scope variables of the same object) and procedure calls (within the same module) to determine whether the generated GUID ultimately lands in a key field. Replace `CreateGuid()` with `Guid.CreateSequentialGuid()`, which produces partially-sequential values that keep index inserts append-only. + +The key check includes the implicit primary key of a table declared without a `keys` section, and the value is recognised however the record is reached — a named variable, `Rec` (tables, pages, request pages, and the `OnRun` trigger of a codeunit with `TableNo`), bare field access inside tables and table extensions, and `this`. ### Example @@ -80,6 +82,7 @@ The rule does not flag the following scenarios: - `CreateGuid()` assigned to fields in **temporary** tables (no SQL backing, so no index fragmentation). - `CreateGuid()` passed as an argument to **event publishers** (idiomatic AL pattern for correlation IDs). - `CreateGuid()` passed to procedures in **external dependencies** where the source code is not available. +- GUIDs returned from, or written to `var` parameters of, helper procedures are not traced back to the caller. If you intentionally need a random GUID in a key field — for example, to prevent callers from guessing adjacent values in a public API — suppress the diagnostic with a pragma: