bcquality/microsoft/knowledge/upgrade/datatransfer-skips-triggers-and-subscribers.md
Jesper Schulz-Wedde 2b5550c346
Some checks failed
Validate knowledge index / validate-index (push) Has been cancelled
Validate AL review fixtures / validate-review-fixtures (push) Has been cancelled
Validate frontmatter and structure / validate (push) Has been cancelled
Improve partner onboarding and documentation navigation (#174)
Lead with a complete plugin quick start and add task-oriented usage, troubleshooting, customization, and contribution guides. Preserve the broader plugin framing, correct conflicting contract guidance, support Agents folder reviews, and align repository validation. Convert existing sample references to clickable links without changing knowledge rules.

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-09-09 17:31:03 +02:00

2.2 KiB

bc-version domain keywords technologies countries application-area
21..
upgrade
datatransfer
validate-trigger
event-subscriber
side-effects
business-logic
al
w1
all

DataTransfer does not fire validation triggers or event subscribers

Description

DataTransfer writes sets directly at the database layer, so row-based triggers and events do not run. For CopyFields, that includes the table OnModify trigger and OnBeforeModifyEvent/OnAfterModifyEvent; direct field assignment also does not call field OnValidate or its validation events. These are separate behaviors: Record.Validate(Field, Value) runs field validation, while Record.Modify(true) runs the table OnModify trigger. Calling Modify(true) does not retroactively validate assigned fields.

For new fields and tables added in the same change this is fine: nothing yet depends on the validation. For pre-existing fields with validation logic, DataTransfer quietly bypasses business logic that may be load-bearing for posting, calculation, or integration scenarios.

Best Practice

Use DataTransfer when set-based transfer is safe and row-level business logic is intentionally unnecessary — initial population of a new field is the canonical case. When an existing field's validation must run, loop through records and call Validate(Field, Value); if the table's modify trigger must also run, follow with Modify(true). If performance requires DataTransfer, document exactly which field-validation and row-modification triggers or subscribers are intentionally bypassed and verify that derived data remains correct.

See sample: datatransfer-skips-triggers-and-subscribers.good.al.

Anti Pattern

Reaching for DataTransfer to update an existing field with non-trivial OnValidate or OnModify logic, without confirming that both validation and row-modification subscribers can be skipped. Replacing it with only Modify(true) is also incomplete when field validation is required; call Validate for that field first.

See sample: datatransfer-skips-triggers-and-subscribers.bad.al.