Repository navigation
knowledge(data-modeling): Init() keeps the primary key; recompute an editable derived field only while unedited - #272
Conversation
…editable derived field only while unedited Adds init-does-not-reset-primary-key-before-reinsert and only-cascade-derived-field-update-when-not-user-overridden, each with good/bad samples, a worklist cue in al-data-modeling-review, and registration in the data-modeling review-fixtures override. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
The derived-field test expects a finding, but its example only contains a table, while the review rule excludes fields that aren't exposed on a page. A reviewer could follow that rule correctly and still fail the test.
Please add a small page exposing Search Name as editable to both examples, or supply that setup in the test context, and make the article and review rule consistent.
One smaller, non-blocking clarification: temporary records also retain their primary key after Init(). Please narrow that exception to cases that assign a new key before inserting.
…articles - Both derived-field examples now include a card page that shows "Search Name" as an editable field, so the expected finding no longer depends on a field the review rule excludes. - Article and review rule now use the same trigger: the target is shown as an editable field on a page of the app. A Caption/ToolTip alone no longer qualifies, and a target shown only as non-editable is excluded. - Init(): temporary records are no longer a blanket exception. They keep their key after Init() too, so they are clean only when the code assigns a new key before each Insert. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, Jesper. Addressed in 5a5c796:
|
Jesper Schulz-Wedde (JesperSchulz)
left a comment
There was a problem hiding this comment.
Thanks, both previous points are addressed.
The added card page exposes another conflict in the examples: Equipment Model has the master-table shape (No. as Code[20], Name, Search Name, and a card), but no No. Series field or OnInsert numbering. The master-numbering rule also reaches both examples and requires that setup. A reviewer following it can therefore report an extra issue, including on the example expected to be clean.
Please make both examples consistent with that rule, or provide neutral test context establishing that the table and numbering already exist and only the derived-field behavior and page are being changed. Preserve the editable-page evidence and the intended finding on the bad example, without accepting unrelated findings on either example.
…ion/data-modeling-init-key-and-derived-field
…ld examples The Equipment Model examples now carry fixture context stating that the table and its card already exist with numbering in place (No. Series field, setup, OnInsert assignment), omitted from the file, and that the change adds only the derived Search Name field, its OnValidate code and its field on the card page. The master-numbering rule therefore has nothing to report on either example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, Jesper. Addressed in 1a02510 (after merging current main):
Local runs: frontmatter, knowledge index and retrieval, skill index, changed paths, fixture contexts and knowledge-response checks all pass. |
Jesper Schulz-Wedde (JesperSchulz)
left a comment
There was a problem hiding this comment.
Thanks, the context addresses the remaining conflict: it establishes that the table and numbering already exist, while the change introduces the derived field and its validation. The examples still show the editable field and preserve the intended behavior. Looks good.
Summary
Two data-modeling mistakes that compile and pass tests on empty data, then fail once real rows exist.
What this adds
microsoft/knowledge/data-modeling/init-does-not-reset-primary-key-before-reinsert.md:Record.Init()leaves the primary key alone (Learn: "Primary key and timestamp fields aren't initialized."). A record variable that just read rows, receivedTransferFields, or was inserted still holds that key. WithoutClear, a separate variable, or a new value for the key field(s) that distinguish the new row,Insertreuses the old key and fails. The failure is common withAutoIncrementkeys, which Learn says must be blank before insert.if not Get() then begin Init(); Insert(); end;; code that advances"Line No."while"Document Type"/"Document No."stay the same; temporary records.microsoft/knowledge/data-modeling/only-cascade-derived-field-update-when-not-user-overridden.md: an editable derived field (for example"Search Name") that the source field'sOnValidaterecomputes unconditionally loses whatever the user typed, with no error. Customer, Vendor, Item and Contact guard the recompute withif ("Search Name" = UpperCase(xRec.Name)) or ("Search Name" = '') then. The article explains why the guard stays safe in everyxRecstate.al-data-modeling-reviewand registration in the data-modeling review-fixtures override. The derived-field cue fires only when the target is shown editable on a page or presented as an alternate/search name.No Base Application change is asked for
The derived-field article describes existing Base Application behaviour. Some tables, such as Work Center and Machine Center, recompute
"Search Name"unconditionally even though the card shows it as editable. The article names them so a reviewer doesn't treat them as a template. It does not ask for them to change, and the cue applies only to new or changed source→target pairs.Evidence
Record.Init()remarks;AutoIncrementproperty remarks; system-defined variables (xRec); Code data type.837ef80:CatalogItemManagement;EDocRecurrentBatchSend, which sets"Entry No." := 0afterTransferFields;DataArchiveMediaField, which sets"Entry No." := 0afterInit().Applies to: all BC versions.
Why data-modeling: both concern how records and keys are created and kept consistent. They sit next to
master-data-must-be-inserted-with-triggerandtransferfields-mirrored-fields-must-match-type-and-length.Test plan
validate_frontmatter.py: 0 errors, 0 warningsTest-ReviewFixtures.ps1: passed, 307 casesTest-ReviewContract.ps1: passedTest-KnowledgeRetrieval.ps1: passed837ef80and the live Learn pages🤖 Generated with Claude Code