How to run a dataport & an exe file thru a command button?

Aravindh_NavisionAravindh_Navision Member Posts: 258
Hi Friends,

My requirement: By clicking a new command button in Posted Invoice form, I must run a dataport followed by running an exe file.

I did a code in dataport (Dataport - OnPreDataport trigger) which stores the text file in specified folder ...
CurrDataport.FILENAME := 'C:\ARG\EInvoice\' + FORMAT(WORKDATE,0, 'Invoice' +  '.txt' ;
... and I wrote in newly created command button's (On Push() trigger) ...
DATAPORT.RUN(DATAPORT::"<Name of the dataport to run>"); // To run a dataport
SHELL('C:\Program Files\Windows NT\Accessories\wordpad.exe'); // To run the exe file - just for an example
C:\Program Files\Windows NT\Accessories\wordpad.exe : is a sample path...

While running the dataport, it should filter to the current record and store in a specific folder. Then after few milliseconds the exe file should get triggered (which uses the extracted data through dataport from the folder - no need to worry about this function.).

Can anyone tell me how to achieve this?

Thanks,
Aravindh.

Comments

  • krikikriki Member, Moderator Posts: 9,110
    Something like this:
    recCurrentRecord.RESET;
    recCurrentRecord.SETCURRENTKEY("....");
    recCurrentRecord.SETRANGE("key field 1","key field 1");
    recCurrentRecord.SETRANGE("key field 2","key field 2");
    DATAPORT.RUN(DATAPORT::"<Name of the dataport to run>",recCurrentRecord);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • PWLPWL Member Posts: 3
    or better:
    DATAPORT.RUN(DATAPORT::"<Name of the dataport to run>",FALSE,recCurrentRecord);

    are you sure to use RUN not RUNMODAL... ?
  • Aravindh_NavisionAravindh_Navision Member Posts: 258
    Anything is fine PWL.. I need a better approach to achieve this... :D

    Aravindh.
  • SogSog Member Posts: 1,023
    Either let the dataport inform NAV that it's done so you can start your exe, or test the folder for editable files and when found start the exe.

    if you have a single instance codeunit, you can let the dataport modify a boolean in the cu so the exe can start. Or you can keep scanning the folder every few milliseconds for files that are editable. If found then you can run them.
    Make sure that the code that's running waiting for the dataport to be finished won't lockup your NAV.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
Sign In or Register to comment.