I have a task to import daily collections from web service into navision 5.0 SP1. Could someone suggest a best way of doing it in .NET.
I’m thinking of 2 ways
Using C/Front post the data into voucher table. I’m not clear on any implications because of this.
2.Using C/Front post the import data to a temp table and invoke a code unit to post the data into vouchers. In this approach I’m not clear on how to invoke codeunit from an executable sitting outside of Navision.
First of all, why do you want to use C/Front to do this? Do you really need to “push” the data into NAV? The reason I’m asking is that there are ways which are much easier, if you do it from NAV and pull in the data. And on top of that then C/Front is not supported in the new versions (NAV 2013 and up), so if you develop a solution in C/Front, then it would not be able to be upgraded when the customer decides to upgrade.
But anyway. If you are going to use C/Front to then it’s best practice to import into a “buffer table” and then use a codeunit to move it to the general journal line table and then invoke the standard posting codeunit.
You should NEVER EVER import anything directly into the general ledger entry (or any other table). There is a lot of extra “stuff” going on when you post something in NAV and it could very easy go wrong.
But as I started by saying, then I would much rather suggest that you build the import from NAV. You can use both XMLPorts or DataPorts from NAV to import it into the general journal lines and then post it from here without too much work. Or if you don’t have access to the data in a file, then it’s not very difficult to create a function within NAV that accesses a standard SQL (or any other ODBC) database and reads the data. Then you can setup the codeunit you create for this into the Job Queue and schedule it to import and post how often you like.
C/Front is one of the thought as I have to call a web service to get the data and use it for import. I can also look at creating a csv and use dataport for import.
If I use dataport, can I invoke it from outside?
Could you point me to some reference or sample code of dataport of general journal entries.
I’ll suggest that you start by reading my blog post about “Which tables to use?”. It tells you a little about exactly what you’re trying to do.: getting entries into the customer ledger entry tables (I assume).
No, dataports cannot be invoked externally. That’s why I suggested that you put it into a codeunit which then first calls the dataport and imports the data, and then uses the standard posting codeunit to post the data. You should then setup the Job Queue to schedule the import to run as often as you like.