Job Queue Execution

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 Replies to “Job Queue Execution”

  1. 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. 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?

  2. 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. 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. Always gives me this error:

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

Leave a Reply