Setting up XMLport

luc50514luc50514 Member Posts: 2
I am posting this for information on how to set up a XMLport because I couldn't find information and how you would set up a XMLport in Navision. I had to learn this on my own. Feel free to comment or correct any or all of my findings. I don't care about being wrong in the beginning as long as I am right at the end. ](*,)

If you open an xml document you will find that the document has a bunch of “<” and “</” these symbols define a tag in the xml document. So <name> is called a beginning tag and </name> is the end tag. Put the two tags together and you have an element. So in the xml document that is sent to us from the internet the very first element is the root element. Some people call this the document type it is just semantics to me. All the elements below the root element they are child elements of the root. Also if an element is inside of another element this element is also called a child of the element. The element containing the child is also called the parent.

<order>root element
<name> Parent element
<first>firstname</first>Child element
<last>lastname</last>Child element
</name>
</order>

When you set up the xml port in Navision you have to set up every element in the xml document. This would include the root element and every element contained in the xml document. To set the xml port to insert a record in a table the parent element has to be set equal to the table and then the child elements will be set to the fields of the table.

TagName TagType SourceType DataSource
OrderHeader Element Text <OrderHeader>
Order Element Table <TableName>(TableName)
OrderNo Element Field <TableName>::Fieldname
CustomerNo Element Field <TableName>::Fieldname
Sell-toName Element Field <TableName>::Fieldname

Notice how the root element is set as text and it has to be included in the port. If you do not have the root element, the port will not write the information directly to the table when the xml port is ran. When you compile the xmlport it will also give you an error message when you compile without the root element. The XMLport writes directly to the table that you specify. We all know that data needs to be checked before we input into the database. For that reason they put a trigger in the xml port called in our case Order - Import::OnBeforeInsertRecord(). We can put our checks in this trigger to check the data and XMLport.SKIP if the data isn’t clean.

This is very basic i know but hopefully the next person wondering how to set one of these up with no documentation will be able to.

Comments

Sign In or Register to comment.