3 AL/BC patterns: Insert/Delete trigger defaults on master data and declined Confirm in OnValidate - #209
Conversation
Three Microsoft-layer articles with good/bad samples: - error-handling/declined-confirm-must-abort-not-partially-apply - data-modeling/delete-master-data-with-trigger - data-modeling/master-data-must-be-inserted-with-trigger Wire targeted worklist cues into al-error-handling-review and al-data-modeling-review and register the samples in review-fixtures.json. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…view Co-Authored-By: Claude Opus 5.5 <[email protected]>
Jesper Schulz-Wedde (JesperSchulz)
left a comment
There was a problem hiding this comment.
Reviewed 4e2a3ead4d246ef7f8bef74186c2c04219029379. The master insert/delete guidance accurately reflects trigger defaults and current Customer/Currency behavior while preserving temporary/staging, owning-table cascade, same-key restore, explicit initialization, and no-postings rebuild exceptions. The declined-confirm rule is scoped to provably orphaned old state, not optional follow-ups or safe pre-write cancellation, and the good sample aborts before the side effect. The package is consistent with existing performance/ownership guidance and all three pairs are registered. Exact-head local frontmatter, knowledge index/retrieval, skill/schema, review-contract, and changed-path fixture validation pass (222 cases). No merge-critical issue found. GitHub validation workflows are awaiting approval and should run before merge.
|
Michael Dieringer (@MichaelDieringer), could you resolve the conflict? Looks good otherwise! |
Insert-only conflicts in al-data-modeling-review.md (scope line, token list, not-applicable list) and evaluation/review-fixtures.json: both sides kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Three articles about silent defaults on record writes and confirmations. All three compile without a diagnostic and pass review by eye.
data-modeling/master-data-must-be-inserted-with-trigger.mdRecord.Insert()does not runOnInsert, becauseRunTriggerdefaults tofalse(Learn).No./No. SerieswhenNo.is blank, the conditional contact and salesperson defaults, Global Dimension 1/2 overwrite,UpdateReferencedIds, and timestamps.Insert(true)34 times against 6 bareInsert(). All 6 fall under the stated exceptions: temporary records, XMLport round-trips (ExportItemData:405,MfgExportItemData:415),CatalogItemManagement, andCopyItem.Insert(true), so migration from an external source is explicitly not an exception.pass-false-to-insert-when-trigger-not-needed.md, so the decision stays per call. There is deliberately no Modify counterpart, because Base App usesModify()without trigger routinely.data-modeling/delete-master-data-with-trigger.mdDelete()/DeleteAll()withouttrue, called from outside the owning table, skips itsOnDeleteguard. Example:Currency.OnDelete(lines 797-820) blocks deletion while open Cust./Vendor/Employee ledger entries exist, andCustomer.OnDeleteruns codeunit 361MoveEntries.Currency.OnDeletecallsCurrExchRate.DeleteAll())JobArchiveManagementrestore)OnBeforeDelete/OnAfterDeletestill run (Learn).error-handling/declined-confirm-must-abort-not-partially-apply.mdOnValidate, the field already holds its new value. A declinedConfirmthat only skips a side effect therefore commits the new value while leaving state tied to the old value orphaned.end else exit, andOpportunity."Campaign No.".if not Confirm(...) then Error('')is shown as the standard abort (InteractionTemplate), and restoringxRecas the alternative (To-do"Team Code").avoid-user-prompts-inside-transactions.mdandjob-queue-handlers-must-not-require-ui.md.Relationship to existing articles: reconciled with and cross-linked to:
pass-false-to-insert-when-trigger-not-neededmaster-table-no-from-number-series-in-oninsertowning-table-must-delete-dependents-in-ondeletedo-not-modify-or-delete-posted-ledger-entriesdatatransfer-skips-triggers-and-subscribersNone are restated.
Verification
837ef8024.Wiring
al-data-modeling-review.mdandal-error-handling-review.mdgain targeted checks.evaluation/review-fixtures.json.Test plan
validate_frontmatter.py: 0 errors (2 pre-existing warnings in unrelated files)Test-ReviewFixtures.ps1: 222 cases / 111 paired articlesTest-ReviewContract.ps1,Test-SkillIndex.ps1,Test-KnowledgeIndex.ps1,Test-KnowledgeRetrieval.ps1: passlicense/clacheck passes (CURABIS ApS company agreement on file)microsoft/knowledge/data-modeling/,microsoft/knowledge/error-handling/)🤖 Generated with Claude Code