Muokkaa

Jaa


DataTransfer.CopyFields() Method

Version: Available or changed with runtime version 10.0.

Copies the fields specified in AddFields with filters from AddSourceFilter, and the join conditions from AddJoins in one bulk operation in SQL.

Syntax

 DataTransfer.CopyFields()

Parameters

DataTransfer
 Type: DataTransfer
An instance of the DataTransfer data type.

Remarks

The DataTransfer object can only be used in upgrade code and it will throw an runtime error if used outside of upgrade codeunits.

Use this method to copy data in fields from one table to another table. For more information, see Transferring Data Between Tables.

Example

In this example, you have two tables, Source and Destination. You're planning on obsoleting field S3 in the Source table. But before you do, you want to copy some values of S3 into the field D3 of the Destination table. Specifically, you only want to copy field S3 in rows where field S2 is equal to A.

local procedure CopyFields()
var
    dt: DataTransfer;
    dest: Record Destination;
    src: Record Source;
begin
    dt.SetTables(Database::Source, Database::Destination);
    dt.AddFieldValue(src.FieldNo("S3"), dest.FieldNo("D3"));
    dt.AddSourceFilter(src.FieldNo("S2"), '=%1', 'A');
    dt.AddJoin(src.FieldNo("PK"), dest.FieldNo("PK"));
    dt.CopyFields();
end;

DataTransfer Data Type
Transferring Data Between Tables
Getting Started with AL
Developing Extensions