Job Queue Entry Pattern

In Microsoft Dynamics NAV, processes can be automated using the Job Queue. The Job Queue asynchronously processes requests as a background service using an NAV Application Service.

Note

An explanation of the implementation of Job Queue Entry Pattern is available at https://www.youtube.com/watch?v=UA2Pq7fv-Dk&list=PLhZ3P-LY7CqmVszuvtJLujFyHpsVN0U_w&index=15.

Most processes can be wrapped in a Job Queue process by implementing Job Queue Entry Pattern.

Note

Job Queue can also execute a report. This pattern describes the usage of Codeunits in Job Queue.

Technical description

Job Queue Pattern requires us to wrap the process into a Codeunit that takes a Job Queue Entry as a parameter. This Codeunit then follows a number of steps.

Preprocessing

During this step, we can test if the Job Queue Entry table contains the information that we need.

Getting records

The Job Queue Entry contains a Record ID that allows us to read a record from a specific table. This record will be the one to be processed.

The Main function

In this step, we execute the automated process. Each process in Dynamics NAV should be designed to be wrapped in a Job Queue Entry, and should therefore avoid any runtime decisions; or if any, they should be omitted.

Note

Runtime decisions are the implementations of STRMENU, CONFIRM, or the running MODAL page objects.

Try to avoid the code cloning of the main function to allow running via the Job Queue Entry.

The following illustrates the structure of the Job Queue Entry Codeunits:

The Main function

Post-processing

Specific tasks related to the background process can be handled in this step, such as handling the Job Queue Status.

Error handling

The source table for the automated process should have a new field Job Queue Status. This field is of the type Option, and has the options: (blank), Scheduled for Posting, and Error & Posting.

The Helper Codeunit, as discussed in the pattern Document History, should set this field to the Scheduled for Posting value when the background processing is activated.

Implementations

This is implemented for Sales and Purchase Posting in Microsoft Dynamics NAV.

Examples

These objects contain examples of the following Pattern:

Object

Description

Codeunit 88

Sales Post via Job Queue

Codeunit 98

Purchase Post via Job Queue

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset