{"title":"LinkTable Property","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/properties/devenv-linktable-property/","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/properties/devenv-linktable-property, 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/properties/devenv-linktable-property","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":"Sets the table that this XML item should be linked to.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Applies to","slug":"applies-to","at":201,"chars":38},{"level":2,"title":"Syntax","slug":"syntax","at":239,"chars":41},{"level":2,"title":"Remarks","slug":"remarks","at":280,"chars":128},{"level":2,"title":"Exporting","slug":"exporting","at":408,"chars":1272},{"level":2,"title":"Importing","slug":"importing","at":1680,"chars":2727},{"level":2,"title":"Related information","slug":"related-information","at":4407,"chars":40}],"text":"> Version: _Available or changed with runtime version 1.0._\nSets the table that this XML item should be linked to. This property is only available for XML items that have a table as their data source.\n## Applies to\n Xml Port Table Element\n## Syntax\n```al\nLinkTable = <field>;\n```\n## Remarks\nThis property works in combination with the devenv-linkfields-property and the devenv-linktableforceinsert-property.\n## Exporting\nIn this example, you are exporting data about specific customers and the orders that they placed. You create an XMLport based on the following database tables:\n A Customer table that contains general information about the customer, such as address, telephone number, and so on.\n A Sales Header table that contains information about the orders placed by these customers.\nIn the Customer table, the primary key is the customer number and is stored in the No. field. In the Sales Header table, each record contains this customer number as a foreign key in the Sell-to Customer No field.\nSet the LinkTable property of the Sales Header XML item to point to the Customer table and set the devenv-linkfields-property of the Sales Header XML item so that the Sell-to Customer No. field is equal to the No. field in the Customer table. This places a filter on the records in the Customer table and ensures that only those records in the Sales Header table that refer to the customers you specified are selected and exported by the XMLport.\nThis corresponds to placing the following AL code in the ../triggers-auto/xmlporttableelement/devenv-onprexmlitem-xmlporttableelement-trigger of the indented data item.\n```al\nSetRange(\"Sell-to Customer No.\",Customer.\"No.\");\n```\n## Importing\nIn this example, you are importing XML data that contains information about new customers as well as details about their first orders. You create an XMLport based on the following database tables:\n A Customer table that contains general information about the customer, such as address, telephone and so on.\n A Sales Header table that contains information about the orders placed by these customers.\nIn the Customer table, the primary key is the customer number and is stored in the No. field. In the Sales Header table, each record contains this customer number as a foreign key in the field called Sell-to Customer No.\nYou must set the LinkTable property of the Sales Header XML item to point to the Customer table and set the devenv-linkfields-property of the Sales Header XML item so that the Sell-to Customer No. field points to the No. field in the Customer table. This ensures that the customer numbers in the incoming data stream are inserted into both the Customer table and the Sales Header table. The incoming data stream must conform to the XML schema that you have defined for your XMLport.\nIn this example, the information you are importing has a header/line relationship-each customer can place many orders. The customer information is the parent of the sales header information. In this kind of relationship the parent information generally methods as a kind of wrapper that encapsulates the information about the children.\nThe schema typically starts by supplying some of the parent information, followed by the information about the children, and it finishes by supplying the last of the parent information.\nWhen the XML stream is processed, it begins with the parent information, for example, the customer number is inserted into the No. field in the Customer table. Next comes the sales header information and the customer number is inserted into the Sell-to Customer No. field in the Sales Header table. The rest of the sales header information is then inserted into that table.\nIn this case, you must use the devenv-linktableforceinsert-property to ensure that the parent information is inserted before the child information. The customer information is inserted into the Customer table before you start processing the sales header information. This makes it possible to validate the sales header information against the customer information as it is inserted.\nAfter the sales header information has been processed, the last of the customer information is inserted into the Customer table.\nIf the customer number already exists, you will receive an error. This means that you will probably have to insert the data into a temporary table, modify it, and then insert it into the correct tables.\n## Related information\ndevenv-properties"}