Dataport + CodeUnit to log

ben5000ben5000 Member Posts: 110
Hi,

I've created an dataport(export) and a codeunit.
The idea is to do an export and keep track of what was exported.

Here is what I'd like to do:

1) Dataport is used to set filters on a record (via requestform)
2) The record is passed to the codeunit which writes the data in a table (log)
3) The export to text file occurs
4) If export succeded then commit the transaction (insert)
5) If export failed then the transaction is not commited

Is it possible to implement?

Thanks

Comments

  • kinekine Member Posts: 12,562
    And what is the problem? If there is error (export failed), the transaction is rolled back automatically. If all is ok, transaction is commited thus log is commited too... Or you need something different?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ben5000ben5000 Member Posts: 110
    The problem is that the export failed but not the import in the log table.
  • kinekine Member Posts: 12,562
    Than you need to run the dataport from codeunit which you run through "if CODEUNIT.RUN then" or you need to use singleinstance codeunit with temporary table for the log which will be flushed somehow after the error (thus again, you need to be able to run code after the report, e.g. by running the code from the codeunit in IF-THEN statement).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ben5000ben5000 Member Posts: 110
    Thanks for your quick reply,

    I passed a wrong parameter from the dataport to the codeunit so the filter was empty for the dataport but it made sense in the codeunit. That's why the codeunit worked and the dataport did not. :)
Sign In or Register to comment.