Home » How to Use Job Queues to Schedule Tasks in Dynamics 365

How to Use Job Queues to Schedule Tasks in Dynamics 365

by Genna Joudrey
9 minutes read

In Dynamics 365, job queues enable users to schedule and run specific reports and codeunits. An example of when you would want to run a job queue is if you want to run the sales statistics report on a weekly basis. This would allow management to track sales by the salesperson each week. This blog post will explain how to set up background posting with job queues, how to create a job queue entry for batch posting, and how to view the status and errors in a job queue.

How to set up background posting with job queues: 

Job queues are an effective tool to schedule the running of business processes in the background, such as when multiple users are trying to post–sales orders, but only one order can be processed at a time. You might want to schedule postings

1. Choose the search  icon, enter Sales & Receivables Setup, and then choose the related link.

2. On the Sales & Receivables Setup page, choose the Post with Job Queue check box.

3. To filter to job queue entries for sales order posting, choose the Job Queue Category Code field, and then select the SalesPost category.

A job queue object, codeunit 88 Sales Post via Job Queue, is created. Proceed to enable it on the Job Queue Entries page.

4. Choose the  search  icon, enter Job Queue Entries, and then choose the related link.

5. On the Job Queue Entries page, choose the New action.

6. In the Object Type to Run field, select Codeunit.

7. In the Object ID to Run field, select 88, Sales Post via Job Queue.

No other fields are relevant for this scenario.

8. Choose the Set Status to Ready action.

9. To verify that the job queue is working as expected, post a sales order. For more information, see Sell Products.

10. Review the Job Queue Log Entries page if the sales order was posted successfully. For more information, see To view status or errors in the job queue.

PRO TIP: If you also want sales documents to be printed when they are posted, select the Post & Print with Job Queue check box on the Sales & Receivables Setup page. If you set up a job that will print documents, and the printer displays a dialog box, your document will be posted but it will not print. The job queue entry will eventually time out, and the Status field will change and reflect Error. Microsoft also recommends that you do not use a printer setup that requires interaction with the display of printer dialog boxes in conjunction with background posting.

How to create a job queue entry for batch posting of sales orders: 

The following example will display how to set the Batch Post Sales Orders report up to automatically post released sales orders at 4 pm on weekdays.

1. Choose the  icon, enter Job Queue Entries, and then choose the related link.

2. Choose the New action.

3. In the Object Type to Run field, select Report.

4. In the Object ID to Run field, select 296, Batch Post Sales Orders.

5. Select the Report Request Page check box.

6. In the Batch Post Sales Orders request page, define what is included during automatic posting of sales orders, and then choose the OK button.

7. Select all check boxes from Run on Mondays through Run on Fridays.

8. In the Starting Time field, enter 4 PM.

9. Choose the Set Status to Ready action.

With this example, sales orders that are ready to post will not be posted every weekday at 4 pm.

PRO TIP: If the job queue cannot post the sales order, the status will be changed to Error and the sales order will be added to the list of sales orders. The user will then have to manually handle it.

After job queues are ready to go, the status can change to one of the following:

– On hold

– ​Ready

– In Process

– Error

– Finished

After a job has finished successfully, it is removed from the list of job queue entries unless it’s a recurring job. If it is, the Earliest Start Time field is adjusted to show the next time that the job is expected to run.

To view status or errors in the job queue: 

 Data that is generated when a job queue is run is stored in the database so that you can troubleshoot job queue errors.

To view status for any job

1. Choose the  icon, enter Job Queue Entries, and then choose the related link.

2. On the Job Queue Entries page, select a job queue entry, and then choose the Log Entries action.

To view status from a sales or purchase document

3. From the document that you have tried to post with the job queue, choose the Job Queue Status field, which will contain Error.

4. Review the error message and fix the problem.

 My Job Queue  

The My Job Queue part on your Role Center shows the job queues entries that you have started, but which are not yet finished. By default, the part is not visible, so you must add it to your Role Center. For more information, see “Change Basic Settings”. The part shoes which documents with your ID in the Assigned User ID field are being processed or are queued, including those related to background posting. The part can tell you whether there has been an error in the posting of a document or if there are errors in a job queue entry. The part also lets you cancel a document posting if it is not running.

To view an error from the My Job Queue part:

1. On an entry with the status Error, choose the Show Error action.

2. Review the error message and fix the problem.

Job queues can help with organization and project automation. If you have integrated Business Central with Dynamics 365 Sales, you can use job queues to schedule when you want to synchronize data for the records you have coupled in both business apps. If you set up job queues to run effectively, you can stay on top of important statistics all in one place. If you have any questions on how to get job queues up and running, feel free to reach out! We have a team of Solution Architects, Consultants, and Developers who are more than willing to help.

You are on the blog right now. If you are interested in our consulting services, visit our website to learn more!