How to know that a dataport successfully finished

KeithMMooreKeithMMoore Member Posts: 59
I am running a routine that examines a directory of text files, imports the files via dataport and then moves the files to an archive directory. I want to be able to confirm that an instance of the dataport succeeded and commit it so that the imported file can be moved or, if it failed, that the process can continue on to the other files.

I saw some old code here from 2006 about "IF dataport.RUNMODAL THEN" but that does not work in 4.06. What are some other ways people have used to confirm that a dataport executed successfully? Thanks.

Comments

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    4.06?

    What version is that?

    AFAK the IF .RUNMODAL THEN works in all versions, UNLESS you are in a transation.
  • ara3nara3n Member Posts: 9,256
    Also if you are doing any integration, I wouldn't use Dataports, instead use a codeunit. open the file and read through it and then close it in a codeunit.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • KeithMMooreKeithMMoore Member Posts: 59
    4.06?

    What version is that?

    AFAK the IF .RUNMODAL THEN works in all versions, UNLESS you are in a transation.
    My bad... it is 4.00.06 - This is a not-for-profit variation of NAV.

    I have the following expression - 'LoadJournal' is the dataport being called.

    LoadJournal.IMPORT(TRUE);
    LoadJournal.FILENAME(Configuration."Processing Path"+pFileName);
    IF LoadJournal.RUNMODAL THEN
    Message('');

    When I try to compile the code I receive an error message saying "The expression is VOID. There must be a TRUE/FALSE expression in the IF..." ??
  • SavatageSavatage Member Posts: 7,142
    OnAfterImportRecord() 
     RecordCount := RecordCount + 1; 
    
    OnPreDataport() 
     RecordCount := 0; 
    
    OnPostDataport() 
    CurrFile.CLOSE; 
    IF CONFIRM('%1 Records Imported / Would You Like To Delete The File?',TRUE,RecordCount) 
     THEN ERASE(CurrDataport.FILENAME);
    

    I use a count and a message
  • KeithMMooreKeithMMoore Member Posts: 59
    Thanks. The reason I want to use the IF .RUNMODAL THEN is to provide as much of a hands-free environment as possible.

    The client will have as many as 20 files in this folder to import daily. I want to be able to 1) commit & move the files that successfully imported, 2) track the files which did not and 3) provide a summary report when the process is completed so that they know what files need attention.
  • KeithMMooreKeithMMoore Member Posts: 59
    Thanks for those articles - very helpful.

    I am still confused hearing that IF. xxx.RUNMODAL THEN should work but it is giving me a failure.
  • Dave_CintronDave_Cintron Member Posts: 189
    If you look at the C/Side help, you will see that there is no ACTION associated with the dataport runmodal, only with Form runmodal, so you can't return a status. The best thing to do is to create log table and have the dataport write a "start" message with a "fail" status, then if it completes, write a "success" status, otherwise the fail remains the same.
    Dave
    Dave Cintron
    Dynamics West
    http://www.dynamicswest.com
Sign In or Register to comment.