{"title":"DataTransfer.AddSourceFilter(Integer, Text [, Any,...]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/datatransfer/datatransfer-addsourcefilter-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-addsourcefilter-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-addsourcefilter-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":"Adds a filter for the source table for the data transfer.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"DataTransfer.AddSourceFilter(Integer, Text [, Any,...]) Method","slug":"datatransferaddsourcefilterinteger-text-any-method","at":0,"chars":2050},{"level":2,"title":"Syntax","slug":"syntax","at":184,"chars":105},{"level":2,"title":"Parameters","slug":"parameters","at":289,"chars":644},{"level":2,"title":"Remarks","slug":"remarks","at":933,"chars":289},{"level":2,"title":"Example","slug":"example","at":1222,"chars":684},{"level":2,"title":"Related information","slug":"related-information","at":1906,"chars":144}],"text":"# DataTransfer.AddSourceFilter(Integer, Text [, Any,...]) Method\n> Version: _Available or changed with runtime version 10.0._\nAdds a filter for the source table for the data transfer.\n## Syntax\n```al\n DataTransfer.AddSourceFilter(SourceField: Integer, String: Text [, Value: Any,...])\n```\n## Parameters\nDataTransfer\nType: datatransfer-data-type\nAn instance of the datatransfer-data-type data type.\nSourceField\nType: ../integer/integer-data-type\nThe field in the source table to filter on.\nString\nType: ../text/text-data-type\nThe filter expression. A valid expression consists of alphanumeric characters and one or more of the following operators: \\<, \\>, \\\\, &, |, and =. You can use replacement fields (%1, %2, and so on) to insert values at runtime.\n*[Optional] Value*\nType: ../any/any-data-type\nReplacement values to insert in replacement fields in the filter expression. The data type of Value must match the data type of 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 copy data in rows or fields from one table to another table. See Transferring Data Bewteen Tables<../../devenv-data-transfer>.\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>"}