start a dataport from a report?

Lars_Ender
Lars_Ender Member Posts: 10
Hello,
I try to start a dataport from a report.
I wrote in the "OnPostReport"-Trigger DATAPORT.RUN(594687)
It doesn't work :(

Lars

Comments

  • kine
    kine Member Posts: 12,562
    can you describe the error?

    Tried you add commit before calling the dataport?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Lars_Ender
    Lars_Ender Member Posts: 10
    hi kine,
    there is no error ... it just nothing happens.
    It seems that the call of the dataport (from the report) not work.

    Lars
  • kine
    kine Member Posts: 12,562
    Try to call it with reqest form else it do not know which file to load... (or try to add some message into the dataport if it is running...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • eromein
    eromein Member Posts: 589
    Does something happen is you run the dataport manually?
    Is the trigger you call this statement from actually getting called / runned?

    Little tip:

    It's better to call it like :

    DATAPORT.RUN(DATAPORT::"Dataport Name");
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • kine
    kine Member Posts: 12,562
    I used one dataport in my one report in this way (and it is working):
        ExpDat.IMPORT(False);  //if you need import then TRUE
        ExpDat.FILENAME(FileName); //file you want export or import...
        ExpDat.RUNMODAL;
    

    ExpDat is variable of type Dataport for the requested dataport...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • eromein
    eromein Member Posts: 589
    Problem solved then?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Lars_Ender
    Lars_Ender Member Posts: 10
    no sorry ... the problem is still the same :(

    the trigger runs (i set a message there).
    if i run the dataport manualy than it works ...
    but if i call it by code - nothing hapens
  • kine
    kine Member Posts: 12,562
    How do you set which file you want to use in the dataport???
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • eromein
    eromein Member Posts: 589
    Yeah, I thinks that's it.

    You probably select a filename manually when you run the dataport. When you run this dataport from the code, you need to set a filename...
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • StephenG
    StephenG Member Posts: 99
    Hi

    From all the postings I have seen in this thread, the one thing that seems to be missing is Filtering before the dataport is Run.
      MyRec.SETFILTER(MyField1,'%!..%2',Value1,Value2);
      MyRec.SETRECFILTER;
      DATAPORT.RUN(DATAPORT::"My Dataport",TRUE,MyRec);
    


    Steve
    Answer the question and wait for the answer.
  • eromein
    eromein Member Posts: 589
    That can't be right...

    SETRECFILTER places a filter on the PK. This is not the solution...
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • kine
    kine Member Posts: 12,562
    You do not need to filter... it will be running for all records - filters will be the problem only if there are more records exported, but not in case that nothing is exported... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • StephenG
    StephenG Member Posts: 99
    eromein wrote:

    SETRECFILTER places a filter on the PK.

    Emiel

    What is the PK?

    This line of code
    MyRec.SETFILTER(MyField1,'%!..%2',Value1,Value2);

    should have been
    MyRec := Rec;

    Kine
    You're right, the problem is "Nothing" is being exported.

    Not a good day so far, so I'm going home and going back to bed.
    Answer the question and wait for the answer.
  • kine
    kine Member Posts: 12,562
    Pls, go to bed, it realy seems that you have some black friday... :whistle:

    If nothing is exported, filter will not help...

    PK is primary key - it means that if you set filter and then do setrecfilter you will have filtered only for the record which is active - in this case nothing (because there is no FIND or NEXT or GET before....) - if someone will use your code, never will get any data... =;
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • nasheer
    nasheer Member Posts: 78
    Hi All

    I am also facing the same problem.

    Here below my code

    Name DataType Subtype
    MyDataPort Dataport (Dataport Name)

    tblJIFile.RESET;
    CLEAR(MyDataport);
    MyDataport.IMPORT(TRUE);
    MyDataport.FILENAME(ImpFilename);
    MyDataport.SETTABLEVIEW(tblJIFile);
    MyDataport.RUN;

    When I run the Dataport manually, it works. But call from the report (as mentioned) doesn't trigger the dataport.

    Please Help.

    Regards
    Nasheer.
  • JEyton
    JEyton Member Posts: 33
    Hi!

    I got exactly the same problem when I try to run a dataport from a report.

    The solution for me was to edit the properties of the dataport. Set value for the UseReqForm on the dataport to 'NO', then i works like a charm.

    Regards Jonas