Hi all,
as part of my diploma thesis I'm preparing some student exercises dealing with Navision 4.0 data import and export. One of the exercises is creating a XMLport for a more complex XML document - a sales order. Setting up the XMLport and importing the data into two new tables (eg. SalesHeaderTmp, SalesLineTmp) isn't hard, but I wonder if it is possible to insert the data into the "real" Sales Header and Sales Line tables (36, 37). So far I didn't have any luck getting that to work. I've mapped all tags of the XML to the corresponding table fields and filled up the missing fields (eg. document type) with a few C/AL statements. When I try to run my XMLport I always get the following message: "The sales header does not exist. Identification fields and values: Document Type='order',No.='[An order no. from my xml]'
Thanks for any suggestions and hints or even a better solution!
René
0
Answers
RIS Plus, LLC
Hi René,
In fact I'm working on xml-ports for converting a foreign program to navision.
I went through this message also. I think it comes from inserting a sales line....
Try this:
in the properties of the tag where you defined table sales line set LinkTableForceInsert to yes and LinkTable to the variable you definded for Sales header. In C/AL code of salesHeader - OnInitRecord you shoud have set Document type to order so that the order header will be created as soon as the xml-port retrieves the order number, read in all the order lines and then goes through the rest of the header elements.
when orderlines are inserted the validation of order number finds the header (doesn't matter that there is only the number and the document typ) and doesn't fail anymore.
hope that helps
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
RIS Plus, LLC
This is to late when you want the document type to be correct in the moment when the header is insertet. this insertion happens at the moment when the first orderline is to be insertet, if you have the property LinkTableForceInsert set to yes.....
This OnBeforeInsertRecord trigger is triggert after insertion of the lines and after assigning all values from elements and attributes inside the element which is assigned to the header, and not when this forced insert takes place.
the assignment of documenttype has to take place either in the OnAfterInitRecord trigger of the header or in a trigger of an element or attribute which comes before the first orderline element.
I stumbled into that trap myself in the first tries :-$
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)
Thanks for the tip.
RIS Plus, LLC
It's not so bad to let the validation in default setting.
You always should try with data, that normally comes in and when there is an error because of validation, you get this and can handle it, eg in reading the value in a variable and put it in the right field with code, after prerequisites are fulfilled.
If you shut off the default, maybe you get this error much later, when s.o. tries to use this data, because you didn't think of a possible validation error. :whistle:
So, when your Problem is solved, please remember the [solved] statement in original posting.....
Michael Schumacher
oh, what day is it? Backup day. OK, let's dump all data to /dev/nul ;-)