Do not use SkipFieldsNotMatchingType to hide required TransferFields mismatches
Record.TransferFields copies values between fields with matching field numbers. Without SkipFieldsNotMatchingType (or with it false), a type mismatch between two fields in the same extension raises a runtime error at the point of transfer.
- microsoftlayer
- data-modelingdomain
- 2examples
- 2pull requests
Rule on GitHub · microsoft layer · data-modeling · BC 16.. · tier official · derived
Description
Record.TransferFields copies values between fields with matching field numbers. Without SkipFieldsNotMatchingType (or with it false), a type mismatch between two fields in the same extension raises a runtime error at the point of transfer. Setting SkipFieldsNotMatchingType to true removes that error: the field is skipped instead, and the rest of the transfer completes normally. The caller gets no indication that a field was not copied.
Best Practice
Use TransferFields(Source) only when every field the destination requires, including primary key fields, is guaranteed to share a matching field number and type with the source; this form defaults InitPrimaryKeyFields to true. Fields with no matching field number, and fields whose types differ across extensions, are skipped regardless of SkipFieldsNotMatchingType — that parameter only governs same-extension type mismatches. If the destination depends on a field that falls into either case, map and validate it explicitly in code rather than relying on TransferFields to catch the gap. Use SkipFieldsNotMatchingType = true only when skipping same-extension type mismatches is an intentional, documented part of the transfer contract.
See sample: transferfields-skip-type-mismatch-can-drop-data.good.al.
Anti Pattern
Using TransferFields(Source, InitPrimaryKeyFields, true) as a generic way to make two evolving table schemas transfer without errors, when the destination depends on every required source field being copied. A type change on either table can turn a previously transferred field into a silently skipped one without making the transfer itself fail.
See sample: transferfields-skip-type-mismatch-can-drop-data.bad.al.
Examples
- Good: transferfields-skip-type-mismatch-can-drop-data.good.al
- Bad: transferfields-skip-type-mismatch-can-drop-data.bad.al
Changed by
- #174 Make BCQuality documentation easier for partners to get started, 2026-09-09
- #153 Promote knowledge for Microsoft-owned review skills, 2026-09-03
From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).