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.
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.
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.
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.
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.
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:
Specific tasks related to the background process can be handled in this step, such as handling the Job Queue Status.
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.