Repository navigation
knowledge(data-modeling): Init() keeps the primary key; recompute an editable derived field only while unedited - #272
Open
Michael Dieringer (MichaelDieringer) wants to merge 2 commits into
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 <noreply@anthropic.com>
Michael Dieringer (MichaelDieringer)
requested a review
from Jesper Schulz-Wedde (JesperSchulz)
as a code owner
November 12, 2026 21:12
Jesper Schulz-Wedde (JesperSchulz)
requested changes
Nov 13, 2026
Contributor
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 <noreply@anthropic.com>
Contributor
Author
|
Thanks, Jesper. Addressed in 5a5c796:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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