mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-08 10:26:52 +01:00
Add mcp knowledge category with 5 rules
Rules derived from BC MCP API page development experience: - api-page-flowfields-must-be-calcfields: FlowFields return empty on API pages unless explicitly CalcFields'd in OnAfterGetRecord - stored-derived-fields-must-not-be-exposed-directly: Stored fields updated only via OnValidate triggers can be stale; recalculate live in OnAfterGetRecord - api-page-key-fields-must-be-editable-on-insert: ODataKeyFields with Editable=false are rejected as unknown properties on POST - api-page-least-privilege-write-access: Create dedicated minimal pages per write concern rather than widening general-purpose pages - agent-must-not-write-business-process-status: Agents must only write developer-tracking fields; business status fields affect invoicing/time registration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c2aaf92748
commit
935d756f05
5 changed files with 190 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
# CURABIS MCP: ODataKeyFields Must Be Editable for Create Operations
|
||||
|
||||
## Core Principle
|
||||
|
||||
Fields declared in `ODataKeyFields` that identify the record must not have `Editable = false` when the API page allows insert. If they are read-only, the OData API rejects them as unknown properties on POST — the create operation fails and the caller receives a `BadRequest` error.
|
||||
|
||||
## Why This Happens
|
||||
|
||||
`Editable = false` on a page field removes the field from the OData write schema entirely. When a consumer POSTs a new record and includes the key field in the body, BC cannot match it to any writable property and rejects the request.
|
||||
|
||||
## Pattern to Avoid
|
||||
|
||||
```al
|
||||
// WRONG: Key field marked Editable = false — cannot be set on create
|
||||
field(projectNo; Rec."Project No.")
|
||||
{
|
||||
Caption = 'projectNo';
|
||||
Editable = false; // blocks insert via API
|
||||
}
|
||||
```
|
||||
|
||||
## Correct Pattern
|
||||
|
||||
```al
|
||||
// CORRECT: No Editable = false — BC controls mutability after insert via ODataKeyFields
|
||||
field(projectNo; Rec."Project No.")
|
||||
{
|
||||
Caption = 'projectNo';
|
||||
}
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- Fields listed in `ODataKeyFields` must not carry `Editable = false` on pages where `InsertAllowed = true`
|
||||
- Fields that should be read-only after creation but writable on insert need no special property — OData key semantics handle immutability after the record exists
|
||||
- Non-key fields that are genuinely read-only may still use `Editable = false`
|
||||
|
||||
## Verification
|
||||
|
||||
On any API page with `InsertAllowed = true`, confirm that every field referenced in `ODataKeyFields` does not have `Editable = false` in its field definition. A create test via the OData endpoint is the definitive check.
|
||||
Loading…
Add table
Add a link
Reference in a new issue