Defining an XMLport schema
You use an XMLport object to export and import data between an external source and Dynamics 365 Business Central. The schema determines which and how data is extracted from or inserted into the Dynamics 365 Business Central database tables through an XMLport. For more information, see XMLport Object.
You build the XMLport schema from nodes. A node can be:
A text element
A text attribute
A table element
A field element
A field attribute
You nest nodes inside other nodes in order to define the structure of the XMLport schema. Use the following keywords to define the structure.
Keyword | Description |
---|---|
textelement |
Defines a new text element in the XMLport. It is used for XML elements that do not map to a database item or when the database does not need the information. |
textattribute |
Defines a new text attribute in the XMLport. It is used for XML attributes that do not map to a database item or when the database does not need the information. |
tableelement |
Defines a new table element in the XMLport. It is used for XML elements that map to a table in the database, which is specified in the SourceTable Property. When the XMLport is run, the code nested inside the table element is iterated for all records in the underlying table. |
fieldelement |
Defines a new field element in the XMLport. It is used for XMLport elements that map to a field in the database, which is specified in the SourceField Property. You must specify it inside the parent table element of the field. |
fieldattribute |
Defines a new field attribute in the XMLport. It is used for XMLport attributes that map to a field in the database, which is specified in the SourceField Property. |
Note
There can only be one <root>
node, which must be an element. If the Format Property is set to Xml, it must be a textelement
node.
There can be several attributes for a single element and their order does not matter. Attribute nodes must be specified inside the element nodes they refer to and before other element nodes. They cannot have nested element nodes.
Snippet support
Typing the shortcut txmlport
will create the basic layout for an XMLport object when using the AL Language extension for Microsoft Dynamics 365 Business Central in Visual Studio Code.
Example
The following example adds the Customer
table as a table element, the Address
field as a field element and the County
and City
fields as field attributes.
schema
{
textelement(Customers)
{
tableelement(Customer; Customer)
{
fieldelement(Address; Customer.Address)
{
fieldattribute(County; Customer.County){}
fieldattribute(City; Customer.City){}
}
}
}
}
For more information about designing XMLports, see XMLport Overview.
For more information about data consistency and validation against possible errors when using XMLports, see the blog post Importing and exporting valid data using XMLports in Dynamics 365 Business Central.
For information about the use of namespaces in XMLports see Using Namespaces with XMLports.
Related information
XMLport Object
XMLport Data Type
Using Namespaces with XMLports
XMLport Triggers
Request Pages
XMLport Overview