Options

XMLPort OnPostXMLPort trigger - WebServices

pfancy79pfancy79 Member Posts: 9
edited 2011-02-15 in NAV Three Tier
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

Comments

  • Options
    deV.chdeV.ch Member Posts: 543
    Could you post your code you use to call the xmlport in your codeunit?

    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...
  • Options
    pfancy79pfancy79 Member Posts: 9
    Hi,

    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
  • Options
    pfancy79pfancy79 Member Posts: 9
    Hi,

    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
  • Options
    deV.chdeV.ch Member Posts: 543
    Yes this is very important but nowhere explained (from what i know). I wrote about it in my blog some time ago.

    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.
Sign In or Register to comment.