{"title":"DataTransfer.AddFieldValue(Integer, Integer) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/datatransfer/datatransfer-addfieldvalue-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-addfieldvalue-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-addfieldvalue-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":"Specifies a source and destination field, where the values from the source field are to be copied to the destination field.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"DataTransfer.AddFieldValue(Integer, Integer) Method","slug":"datatransferaddfieldvalueinteger-integer-method","at":0,"chars":1972},{"level":2,"title":"Syntax","slug":"syntax","at":318,"chars":97},{"level":2,"title":"Parameters","slug":"parameters","at":415,"chars":261},{"level":2,"title":"Remarks","slug":"remarks","at":676,"chars":468},{"level":2,"title":"Example","slug":"example","at":1144,"chars":684},{"level":2,"title":"Related information","slug":"related-information","at":1828,"chars":144}],"text":"# DataTransfer.AddFieldValue(Integer, Integer) Method\n> Version: _Available or changed with runtime version 10.0._\nSpecifies a source and destination field, where the values from the source field are to be copied to the destination field. The data types of the fields must match, except CODE to TEXT which is allowed.\n## Syntax\n```al\n DataTransfer.AddFieldValue(SourceField: Integer, DestinationField: Integer)\n```\n## Parameters\nDataTransfer\nType: datatransfer-data-type\nAn instance of the datatransfer-data-type data type.\nSourceField\nType: ../integer/integer-data-type\nThe source table field.\nDestinationField\nType: ../integer/integer-data-type\nThe destination table field.\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 when copying data in rows or fields of table to rows or fields of another table. See Transferring Data Between Tables<../../devenv-data-transfer>.\n> NOTE\n> Copying the SystemID and data audit<../../devenv-table-system-fields#audit> fields using CopyRows is supported in Business Central version 21.5 and later.\n## Example\nIn this code example, you copy the PK and S3 fields in the Source table for all rows where S2 equals A and add them as new rows in the Destination table. You use AddConstantValue method to give the field D2 the value X in the inserted rows.\n```al\nlocal procedure CopyRows()\nvar\n    dt: DataTransfer;\n    src: Record Source;\n    dest : Record Destination;\nbegin\n    dt.SetTables(Database::Source, Database::Destination);\n    dt.AddFieldValue(src.FieldNo(\"PK\"), dest.FieldNo(\"PK\"));\n    dt.AddFieldValue(src.FieldNo(\"S3\"), dest.FieldNo(\"D3\"));\n    dt.AddConstantValue('X', dest.FieldNo(D2));\n    dt.AddSourceFilter(src.FieldNo(\"S2\"), '=%1', 'A');\n    dt.CopyRows();\nend;\n```\n## Related information\ndatatransfer-data-type\nGetting Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}