diff --git a/content/docs/analyzers/PlatformCop/PC0031.md b/content/docs/analyzers/PlatformCop/PC0031.md index 0d5176e..bab5ec9 100644 --- a/content/docs/analyzers/PlatformCop/PC0031.md +++ b/content/docs/analyzers/PlatformCop/PC0031.md @@ -48,7 +48,9 @@ The diagnostic is not raised for `Modify`, `ModifyAll`, `DeleteAll`, or `Init`. The diagnostic is also suppressed when the write operation is inside a conditional branch (`if`, `case`, `while`, `for`, `foreach`), because the write may only execute on a path where the record was not loaded via partial records. `repeat..until` loops are still flagged because the body always executes at least once. -Temporary record variables (no SQL backing, no JIT load) and record variables where `Clear()` or `Reset()` is called between the `SetLoadFields` and the write operation (resetting the partial records state) are also skipped. +Temporary record variables (no SQL backing, no JIT load) are skipped, and so is a record variable whose partial-records state is reset or handed off between the partial read and the write operation: `Clear()`, `Reset()`, `SetLoadFields()` without arguments, passing the variable by `var` to a procedure or event publisher, passing it to `Codeunit.Run`, `Page.Run` or a similar built-in, or calling a table procedure on it. The callee may reset the load selection, so the write is no longer known to JIT-load. Passing a `Record` variable by value does not suppress the diagnostic: the callee works on a copy with its own load selection. A `RecordRef` passed by value still refers to the same table instance, so it does suppress it. + +The rule analyzes one procedure or trigger body and its local variables only. Global variables, parameters, flows through other procedures and event subscribers are not analyzed, because the record's load state is not visible there: which procedure ran first on a global, what the caller did before passing a parameter, or whether a publisher loaded the record partially cannot be determined statically, and procedures from a dependency have no body to inspect. A subscriber that needs additional fields of a record it receives should call `AddLoadFields` rather than `SetLoadFields`, which would overwrite the publisher's selection. ### See also