TRANSFERFIELDS Function (Record)

Copies all matching fields in one record to another record.


Record.TRANSFERFIELDS(FromRecord [, InitPrimaryKeyFields])

Parameters

Record

Type: Record

The record to which you want to copy the contents of the fields in FromRecord.

FromRecord

Type: Record

The record from which to copy.

InitPrimaryKeyFields

Type: Boolean

Default: true

If this parameter is true and the records are in the same table, both the timestamp and the Primary Key fields of the destination record will be changed.

If this parameter is true and the records are not in the same table, the Primary Key fields of the destination record will be changed (if the fields fulfill the conditions specified above) but the timestamp of the destination record will not be changed.

If this parameter is false, the timestamp or the Primary Key fields of the destination record will not change.

TRANSFERFIELDS copies fields based on the Field No. Property of the fields. For each field in Record (the destination), the contents of the field with the same Field No. in FromRecord (the source) will be copied, if such a field exists.

The fields must have the same data type for the copying to succeed (text and code are convertible, other types are not.) There must be room for the actual length of the contents of the field to be copied in the field to which it is to be copied. If any of these conditions are not fulfilled, a run-time error will occur.

This example shows how to use the TRANSFERFIELDS function with a BLOB field. If you are copying a record that contains a BLOB field, you must calculate the BLOB field before it can be copied with the rest of the record. This example requires that you create the following variables in the C/AL Globals window.

Variable name DataType Subtype

GLAccountRec

Record

G/L Account

FromRecord

Record

G/L Account

…
IF GLAccountRec.Picture.HASVALUE THEN
  GLAccountRec.CALCFIELDS(Picture);
GLAccountRec.TRANSFERFIELDS(FromRecord);
GLAccountRec.INSERT(TRUE);

Community Additions

ADD
Show: