Wednesday, May 1, 2013

Job Queue and NAS in Microsoft Dynamics NAV

This article explains how to configure and use the Job Queue functionality in Microsoft Dynamics NAV together with the Navision Application Server (NAS) to run background tasks automatically, without user intervention.


Background: Job Scheduler vs Job Queue

The Job Queue feature was introduced in Microsoft Dynamics NAV 5.0 as a replacement for the earlier Job Scheduler functionality available in NAV 4.0.

The key improvement with Job Queue is that it allows multiple background tasks to be scheduled and executed automatically by NAV, without requiring a logged-in user. These tasks are executed by NAS in the background based on predefined schedules.


What Is Job Queue and What Is NAS?

Job Queue provides a centralized queue where background tasks are defined, scheduled, enabled, or disabled. Using Job Queue, you can control:

  • When a task starts

  • How often it runs

  • Whether it repeats

  • Whether it is active or paused

NAS (Navision Application Server) acts as the execution engine. It continuously monitors the Job Queue and triggers the defined tasks at the scheduled times.

In short:

  • Job Queue = task definition and scheduling

  • NAS = background task execution


Main Components of Job Queue

The Job Queue functionality is supported by the following system tables:

  • Job Queue Setup (Table 470)

  • Job Queue Process (Table 471)

  • Job Queue Entry (Table 472)

  • Job Queue Response (Table 473)

  • Job Queue Log Entry (Table 474)

The most important table is Job Queue Entry (472), which stores the actual job definitions.


Steps to Use Job Queue with NAS

Step 1: Install Microsoft Dynamics NAV Application Server (NAS)

  1. Install the Microsoft Dynamics NAV Application Server.

  2. Ensure the NAS service is correctly registered in NAV.

  3. Configure the NAS Startup Parameter as:

    JOBQUEUE

This tells NAS to process tasks defined in the Job Queue.

Important:
NAS must always run without any user interface. Any GUI-related code must be disabled.


Step 2: Create Job Queue Entries

To schedule a background task, you must create a Job Queue Entry.

Example: Automating “Adjust Cost – Item Entries”

Suppose you want to automate Report 795 – Adjust Cost - Item Entries.

Before scheduling:

  • Make sure the report does not use GUI elements

  • Use GUIALLOWED() checks where required


Step 3: Define Job Details (Job Queue Entry Card)

Open Job Queue Entry Card (Form 673).

In the General tab:

  • Object Type to Run: Report

  • Object ID to Run: 795

  • Earliest Start Date/Time: First execution date and time

This defines what will run and when it can start.


Step 4: Configure Recurrence

In the Recurrence tab, define how often the task should run.

Example 1: Run every 2 minutes between 8:00 AM and 6:00 PM

  • Set recurrence interval to 2 minutes

  • Define start and end times accordingly

Example 2 (NAV 2013):

Run Adjust Cost – Item Entries at 2:00 AM on weekdays only:

  • Set execution time to 2:00 AM

  • Select Monday–Friday

  • Exclude weekends


Step 5: Activate the Job

Once all details are defined:

  • Click Set Status to Ready

This marks the job as active and eligible for execution by NAS.


Step 6: Enable Job Queue Processing

Open Job Queue Setup (Form 670).

  • Ensure Job Queue Active is selected

If you need to temporarily stop all background jobs, simply clear this checkbox.


Summary

The Job Queue combined with NAS allows Microsoft Dynamics NAV to:

  • Run reports and codeunits automatically

  • Execute tasks without user login

  • Schedule recurring background processes reliably

This functionality is essential for automation scenarios such as:

  • Cost adjustments

  • Data synchronization

  • Periodic batch jobs

  • System housekeeping tasks

Understanding Job Queue and NAS is critical when maintaining legacy NAV systems and during upgrades to newer platforms.




How Job Queue and NAS Work Together (Visual Explanation)

The diagram above illustrates how Job Queue and Navision Application Server (NAS) work together in Microsoft Dynamics NAV to execute background tasks automatically, without user interaction.


Step-by-Step Flow Description

1️⃣ Job Definition (Job Queue Entry)

The process begins when a job is defined in the Job Queue Entry table.
Here, you specify:

  • Object Type (Report / Codeunit)

  • Object ID

  • Start date and time

  • Recurrence rules

  • Status (Ready / On Hold)

This defines what should run and when.


2️⃣ Job Queue Setup Validation

The Job Queue Setup determines whether background processing is enabled globally.

  • If Job Queue Active = TRUE, processing continues

  • If disabled, no jobs are executed, even if they are marked as Ready


3️⃣ NAS Monitors the Job Queue

The Navision Application Server (NAS) runs continuously in the background with the startup parameter:

JOBQUEUE

NAS periodically checks the Job Queue for:

  • Jobs marked as Ready

  • Jobs whose Earliest Start Date/Time has been reached

  • Jobs matching the defined recurrence rules


4️⃣ NAS Executes the Job

When a job is due:

  • NAS triggers the specified Report or Codeunit

  • The execution happens without any user interface

  • All GUI-related logic must be suppressed using GUIALLOWED()

This allows NAV to run batch jobs safely in the background.


5️⃣ Job Processing and Logging

During execution:

  • Processing details are written to Job Queue Process

  • Execution results are recorded in Job Queue Log Entry

  • Success, warnings, or errors are logged for review

If an error occurs, the system records the failure and may retry based on configuration.


6️⃣ Recurrence Handling

If the job is recurring:

  • NAS calculates the next run time

  • The Job Queue Entry remains active

  • The cycle repeats automatically

If the job is one-time only:

  • It completes and stops unless reactivated manually


High-Level Summary (One-Glance Understanding)

Job Queue EntryJob Queue Setup (Active?)NAS (JOBQUEUE)Execute Report / CodeunitLog ResultsNext Run (if recurring)

Why This Architecture Matters

This design allows NAV to:

  • Automate heavy processing tasks

  • Run jobs outside business hours

  • Eliminate dependency on logged-in users

  • Centralise scheduling and monitoring

It is especially critical for:

  • Cost adjustment jobs

  • Data synchronisation

  • Period-end processing

  • System maintenance routines


Important Note for Business Central Upgrades

While NAS is specific to classic NAV, understanding this flow is essential when upgrading to Business Central, where similar functionality is handled by:

  • Job Queue Dispatcher

  • Server task scheduler

  • Background sessions



Wednesday, January 9, 2013

xp_ndo_enumusergroups and xp_ndo_enumusersids


Dynamics NAV requires two extended stored procedures from xp_ndo_x64.dll to exist on SQL Server. In the case of these procedures are not found in the SQL Server, you will end up receiving an error message when trying to log on using Windows Authentication:

Here is the solution;
STEP 1:
Manually copy the relevant file from the Product CD to the path given below depending on the Windows version you are running.

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn

STEP 2:
Run the below scrip file on the SQLQuery Screen. Please note that the below scripts refer to windows 64 bit version. Therefore, if you will be required replace the xp_ndo_x64.dll with xp_ndo.dll


USE master
EXEC sp_addextendedproc xp_ndo_enumusersids, ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\xp_ndo_x64.dll’

GO
GRANT EXECUTE
ON [xp_ndo_enumusersids]
TO PUBLIC
GO

USE master
EXEC sp_addextendedproc xp_ndo_enumusergroups, ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\xp_ndo_x64.dll’
GO

GRANT EXECUTE
ON [xp_ndo_enumusergroups]
TO PUBLIC
GO

Business Central SaaS Extension Design: Implementing Plant Tracking with AL Event Subscribers

  Extending Business Central SaaS: Plant Tracking Using AL Extensions  1️⃣ Problem Statement In many manufacturing and service-oriented or...