{"title":"DataTransfer.CopyFields() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/datatransfer/datatransfer-copyfields-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/datatransfer/datatransfer-copyfields-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/datatransfer/datatransfer-copyfields-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Copies the fields specified in AddFields with filters from AddSourceFilter, and the join conditions from AddJoins in one bulk operation in SQL.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":205,"chars":47},{"level":2,"title":"Parameters","slug":"parameters","at":252,"chars":109},{"level":2,"title":"Remarks","slug":"remarks","at":361,"chars":279},{"level":2,"title":"Example","slug":"example","at":640,"chars":695},{"level":2,"title":"Related information","slug":"related-information","at":1335,"chars":205}],"text":"> Version: _Available or changed with runtime version 10.0._\nCopies the fields specified in AddFields with filters from AddSourceFilter, and the join conditions from AddJoins in one bulk operation in SQL.\n## Syntax\n```al\n DataTransfer.CopyFields()\n```\n## Parameters\nDataTransfer\nType: datatransfer-data-type\nAn instance of the datatransfer-data-type data type.\n## Remarks\nThe DataTransfer object can only be used in upgrade code and it will throw an runtime error if used outside of upgrade codeunits.\nUse this method to copy data in fields from one table to another table. See Transferring Data Between Tables<../../devenv-data-transfer>.\n## Example\nIn 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.\n```al\nlocal procedure CopyFields()\nvar\n    dt: DataTransfer;\n    dest: Record Destination;\n    src: Record Source;\nbegin\n    dt.SetTables(Database::Source, Database::Destination);\n    dt.AddFieldValue(src.FieldNo(\"S3\"), dest.FieldNo(\"D3\"));\n    dt.AddSourceFilter(src.FieldNo(\"S2\"), '=%1', 'A');\n    dt.AddJoin(src.FieldNo(\"PK\"), dest.FieldNo(\"PK\"));\n    dt.CopyFields();\nend;\n```\n## Related information\ndatatransfer-data-type\nTransferring Data Between Tables<../../devenv-data-transfer>\nGetting Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}