The Job Queue granule (3,810) in version 5.0 and later can be used to automate tasks by starting Nav Application Server with the parameter JOBQUEUE.  Everyting that Job Queue starts is started with a record in the table Job Queue Entry.  However, there are built in batches, like report 795, Adjust Cost – Item Entries, that Job Queue can start with some help.  Here is a Report that I use to start built in batches from Job Queue.

Here is a zip file with the code needed.

16 thoughts on “Job Queue Execution

  1. Mark says:

    How is this different from just running say report 795 from jobqueue? You still need to modify them to not display and dialogs, correct?

    1. This will have GUIALLOWED = FALSE and ISSERVICETIER = TRUE

      1. Michiel says:

        Hi Gunnar,

        Looks great, your solution for easy scheduling of jobs. Saves us the time for customizing reports and codeunits. Tested a little with 2 reports, 795 and 5199. The good news: both reports run without any error generated in the Job Queue Log Entries! The bad news: none of the reports seem to have done their job. I.e. create a valued adjustment journal or update the Questionnaire Profile answers.
        I used the Parameter String as described: Report::795 and Report::5199.
        Am I missing something here? Any additional setup needed?

        1. Hi Michiel,

          I did not need to do anything else to get this to work.

          1. Michiel says:

            Okay, I’ll test again. Thanks!

  2. Daniel Heder says:

    Hello
    This seems like a great idea. Unfortunately it does not seem to work for me. In Report 795 there is a call to codeunit 5895 Inventory Adjustment:
    “InvtAdjmt.MakeMultiLevelAdjmt;”
    And in this codeunit the first thing that happens (almost) is that a Window is opened:

    CLEAR(LevelNo);
    MaxLevels := 100;
    WindowUpdateTime := TIME;
    IF NOT IsOnlineAdjmt THEN
    OpenWindow;

    This makes the Jobqueue halt, how did you guys get around this? You could ofc set the variable IsOnLineAdjustment to TRUE but then we would never get the dialog even when manually running report 795.

    1. I changed the OpenWindow function in codeunit 5895 to make sure that the window is only opened if running from a client.

      OpenWindow()
      //#01-
      IF GUIALLOWED THEN BEGIN
      //#01+
      Window.OPEN(
      Text000 +
      ‘#1########################\\’ +
      Text001 +
      Text003 +
      Text004 +
      Text005);
      WindowIsOpen := TRUE;
      //#01-
      END;
      //#01+

  3. vaibhav says:

    when i run report 795, Adjust Cost – Item Entries through job queue in runs in infinite loop it it take almost more than 24 hrs

    1. Perhaps you can try one Item at a time ?

      A Batch looping through Item:

      Item – OnPreDataItem()
      PostingDate := TODAY;

      Item – OnAfterGetRecord()
      “Cost is Adjusted” := FALSE;
      MODIFY;

      ItemApplnEntry.LOCKTABLE;
      IF NOT ItemApplnEntry.FINDLAST THEN
      EXIT;
      ItemLedgEntry.LOCKTABLE;
      IF NOT ItemLedgEntry.FINDLAST THEN
      EXIT;
      AvgCostAdjmtEntryPoint.LOCKTABLE;
      IF AvgCostAdjmtEntryPoint.FINDLAST THEN;
      ValueEntry.LOCKTABLE;
      IF NOT ValueEntry.FINDLAST THEN
      EXIT;

      Item2 := Item;
      Item2.SETRECFILTER;
      InvtAdjmt.SetProperties(FALSE,FALSE);
      InvtAdjmt.SetFilterItem(Item2);
      InvtAdjmt.MakeMultiLevelAdjmt;
      COMMIT;

      Item – OnPostDataItem()
      UpdateItemAnalysisView.UpdateAll(0,TRUE);

  4. Nuno says:

    Always gives me this error:

    You cannot use C/AL variables of type DIALOG when running the Application Server for Microsoft Dynamics NAV Classic.

    1. In older versions of NAV you need to disable all confirm and message dialogs.

      1. Nuno says:

        My version is 2009 R2.

        1. That is an older version.

          1. Nuno says:

            OK, How to do that in this NAV?

          2. You need to change the code you are executing. You can use the variable GUIALLOWED that will give True for the Client but False for NAS.

          3. Nuno says:

            Thanks, worked fine.

Leave a Reply

%d bloggers like this: