TransferFields type mismatch (PC0020)

When using TransferFields between two records, fields with matching names but different types will not be transferred and may cause unexpected data loss. This rule identifies potential type mismatches.

Example

If you have two tables with a field named “Amount” but one is Decimal and the other is Integer, TransferFields will not copy that field:

codeunit 50100 MyCodeunit
{
    procedure CopyRecord()
    var
        SourceRec: Record SourceTable;
        TargetRec: Record TargetTable;
    begin
        TargetRec.TransferFields(SourceRec); // TransferFields type mismatch [PC0020] - Amount field has different types
    end;
}

Review the field definitions and consider manually assigning mismatched fields with appropriate conversion.

See also

  • PC0021 - TransferFields name mismatch