Options

Parameters from Form to Dataport

KennethPKennethP Member Posts: 3
I have made a dataport that can import data into a General Journal. I have also made a button in Form 39 "General Journal", that starts the dataport.
My problem is that I do not want the user to choose the: "Journal Template Name" and "Journal Batch Name" in the dataport, but simply send these from the form. I have not been able to do that. Is it possibly? If so, how?

Regards

Comments

  • Options
    DenSterDenSter Member Posts: 8,304
    Sure that is possibly :D

    Add two global code10 variables to your dataport (TemplateName and BatchName). Add a function called SetValues to your dataport, with two parameters (parTemplateName and parBatchName). In the function, you write the following code:
    TemplateName := parTemplateName;
    BatchName := parBatchName;
    
    Then, in the OnPush trigger of your button, you call your new function with the current template and batchname, so that looks something like this:
    MyDataport.SetValues("Journal Template Name","Journal Batch Name");
    MyDataport.RUNMODAL;
    
    Make sure that your dataport is a variable of the datatype dataport, otherwise this won't work. By calling the SetValues function from the General Journal Form, you put values in the global variables that you can then use throughout your dataport.

    Good luck, HTH 8)
  • Options
    madmatmedmadmatmed Member Posts: 12
    Apart from that, if you don't want to use a dataport - instance, you can start the dataport with
    "Gen. Journal Line".RESET;
    "Gen. Journal Line".SETRANGE("Journal Template Name", 'WHATEVER');
    "Gen. Journal Line".SETRANGE("Journal Batch Name", 'WHATEVER');
    DATAPORT.RUNMODAL(DATAPORT::"Import Gen. Journal Line", TRUE, "Gen. Journal Line");
    
    Of course I agree about everything my predecessor proposed.

    Good luck.
  • Options
    KennethPKennethP Member Posts: 3
    Thanks for the solutions. I have tried them both with succes, so I am glad :D
Sign In or Register to comment.