Parameters for Report starting via Job Scheduler

fve
fve Member Posts: 28
Hi,

Our Sales-invoice Report is running a long time lately, so we would like to schedule to run our Sales Invoice Report during the night using the Job Scheduler.

Is it possible to use parameters, to run the report only for a certain period (e.g. run the report for all invoices of last week).

We would also like to schedule other reports this way.
So it would be nice to automate this with parameters for every report.

However, we don't know if this is possible.

Comments

  • Alex_Chow
    Alex_Chow Member Posts: 5,063
    Out of the box, no.

    You'll need to set implicit filters in the report to print what you need.
  • kine
    kine Member Posts: 12,562
    The reports can be customized and some "parameter passing" method can be used to set the parameters. It is not easy, but it is not too hard. I made it... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Waldo
    Waldo Member Posts: 3,412
    There is no way to make it 100% dynamically, because there is no way (in my knowledge) that you can pass a recordref to a REPORT.RUN - statement.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • fve
    fve Member Posts: 28
    Thanx for the replies.
    Back to the drawing table :lol:
  • Marije_Brummel
    Marije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Scheduling the report might be a solution, but have you looked at the queries that are in the report? You might be able to speed it up.

    Depending if you are running SQL or C/SIDE you can use the client monitor and/or SQL Profiler to look at the statements and database usage.

    What also often can help a lot is moving to Temptables before reporting and report on the buffers.
  • kine
    kine Member Posts: 12,562
    Waldo wrote:
    There is no way to make it 100% dynamically, because there is no way (in my knowledge) that you can pass a recordref to a REPORT.RUN - statement.

    Yes, this PUSH method is not possible, but you can create support library with easy functions which you can use in the report to PULL the parameters. In this case you just needs to add few lines of code into each report you want to use in this module and you are done... :-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Waldo
    Waldo Member Posts: 3,412
    True, but for end users this is not really a "workable" solution. (can you even write code on a report when you buy a report designer granule ... ?).
    Everything should be possible by just setting up some parameters...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • kine
    kine Member Posts: 12,562
    You can write code in report when you have report designer. And yes, it is not much enduser-frendly. But for developer it is just few minutes of work to extend some report when you have such a support library (plus testing etc. which can be much more). And yes, there is no general solution which don't require additional changes in code per report.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • DenSter
    DenSter Member Posts: 8,307
    Something like that is an easy thing for a solution center. I've done something like that to run MRP in the scheduler. What you'd have to do is add setup fields to store the parameters that the report should use, add some functionality to the report to be able to receive the parameters, create a codeunit to retrieve the parameters and set them into the report, and put the codeunit in the scheduler.
  • Waldo
    Waldo Member Posts: 3,412
    What we have been investigating (and still are) is a way to expand our NAS Scheduler, to be able to dynamically schedule reports ... and pass filters. User shouldn't have to add code to any report.
    It IS possible when you use a very (VERY) big CASE-statement, but that is off course not what we want :wink: . We also want to include custom tables dynamically.
    We concluded this was a no-go, and we are handling these requests now the same way as you are mentioning.
    :|

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • DenSter
    DenSter Member Posts: 8,307
    Should have called me Eric, I'd be able to tell you in two minutes :mrgreen:
  • kine
    kine Member Posts: 12,562
    DenSter wrote:
    Should have called me Eric, I'd be able to tell you in two minutes :mrgreen:

    Me too... :-) :whistle:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Waldo
    Waldo Member Posts: 3,412
    Yes, but I never take "no" for an answer :wink:
    Therefore ... still under investigation (luckily not fulltime :wink: )

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • themave
    themave Member Posts: 1,058
    As an end users we do this, and you don't really need your solution center to do it for you, make a copy of the report you want to run, leaving your original intact, makes future upgrades much easier, and you can test it without missing up your original.


    Then make a small modification to the new report. since we know when we want to run it, say each Saturday night in the job schedular. we know what the filter needs to be.

    it needs to be the range

    (today -7days) to (today), that covers the full week

    so we add two variables to the report

    FromDate := TODAY - 7;
    ToDate := TODAY ;

    then set your filter using the above dates

    Record.SETFILTER(Field, String, [Value],...)

    so depending on the report,

    "Sales Invoice Header".SETFILTER(DateFilter,%1..%2,FromDate,ToDate)

    This is definitely within your ability to do, with a little practice. I am sure it can be done a lot better by a solution center, they can make a separate NAS job scheduler for you, modify the reports, ect ect ect, and in a month or two you can have it working, or you can spend a little time right now, get it done a little less eloquently, and be a lot smarter for the effort.