Hi,
I have written an XMLPort that is being used to export and import Sales Quotes into Navision. This is exposed out through a webservice.
I have encountered some strange behaviour on the OnPostXMLPort trigger in that it seems to run through this trigger twice on a webservice call. I have tested it through the client and it works fine.
The imported sales quotes can either be new quotes or updates to existing ones so I have set the tables to be temporary and then loop through them on the OnPostXMLPort trigger. I kept getting errors stating the record already exists.
Further investigating lead me to write a test import xmlport that in the OnPostXMLPort trigger tried to insert a record into a simple 2 field table with a static entry no. of 1. The table was empty before running the import process but still errored with Record already exists.
Has anyone come across this behaviour before or explain why this may be happening?
Kind regards
Paul
0
Comments
i assume you start your xmlport via .import by code, which is not needed if your xmlport is a parameter var. The Webservice-Service does the call of the import/export function itself!
you can also reduce your execution time to a half whithout the call...
Thanks for your reply. I am indeed calling .import in my codeunit.
I am also using the IMPORTFILE parameter as well so that I can use this xmlport for both import of singular quote and export of a filtered set of quotes.
I will test this and let you know.
I was following the example posted on http://blogs.msdn.com/b/nav/archive/2009/11/06/using-dataports-with-web-services.aspx which states that you have to call IMPORT.
Many thanks
Paul
Thanks again. I have tested this and it now works as expected.
Just another quick question, at what point does the IMPORT / EXPORT on the XMLPort get called. Is it the first thing in the codeunit function or is it after any other code?
Thanks
Paul
I can't tell you for sure when the function is called, but any filtering by code etc gets applied, so i assume the code is called before the import/export.