How To Manage D365 Batch Jobs

Share this:

Previously, you learned how to use batch jobs to automate and offload recurring tasks to the server. In this article, we will cover how to manage D365 batch jobs. This includes jobs that will run once. As well as those running on a recurrence. When a batch job has an error, or stops running, a user needs to be informed. Then, take action to resolve the issue.

Manage Batch Jobs

Most likely, you are running a Microsoft Dynamics 365 for Finance and Operations system that already has many batch jobs running. The question becomes: How do we keep those jobs running effectively?

The best place to manage D365 batch jobs is on the “Batch jobs” form in D365. Go to System administration>Inquiries>Batch jobs. Or simply search for ‘Batch jobs’ in the search field.

In particular, this form shows all of the batch jobs that have setup to run. This includes batch jobs that were setup to run once. As well as those that are setup with a recurrence.

In the next article I will explain some technique’s for monitoring all batch jobs as whole. For this article, let’s focus on managing specific batch jobs.

Starting with creating a batch job directly from this form, I will cover each of the key areas that are helpful to know to manage D365 Batch Jobs. Please also see Microsoft’s overview of this topic.

Find An Existing D365 Batch Job

Again, most people usually are starting with a system that is already running many batch jobs. The first thing most people want to do is either investigate whether a particular batch job is running. Or, if it is running, did it fail to finish successfully. For this, we need to find the batch job in the Batch job form.

To start, I usually filter the ‘Job description‘ column to find the batch job I am interested in. But, how do I know the description of the batch job?

When you run a batch job, and the dialog opens, up there will be text under the ‘Task description’ field. In the last article, we were invoicing a sales order. And the task description was “Order invoice”.

Each batch job as a default description. And so this can be used to find the batch job in the Batch jobs form in Microsoft Dynamics 365 for Finance and Operations. Search for ”Order invoice”.

Notably, you can edit this text to be whatever you would like. This is very useful. Often times, there may be many instances of the batch jobs in the grid with the same Job description. You can filter by the “Scheduled start date/time” column to find the job you are interested in. Alternately, you can modify the ‘Task description’ of the batch job to be something unique, so that you can more quickly find that exact instance of the batch job you are reviewing. I will sometimes add a prefix to the existing task description.

After searching for ‘Order invoice‘, I found one record in the grid. I can see that the ‘Status‘ field is set to ‘Ended‘. What does this mean?

Batch Job Status

In order to manage D365 batch jobs, it is very important to understand what each Batch job Status mean. See each description below.

  • Waiting– When a batch job is first created, it starts with a status of ‘Waiting‘. The Batch Job Service will pick up and execute the process at the next recurrence scheduled. The job could be scheduled to run right away. Or, it could be scheduled to run at a certain time in the future. Check the ‘Scheduled start date/time‘ column for the next time the job is scheduled to run.
  • Executing – This indicates the job is actively being executed. User can push the ‘refresh’ button in the top right of the form if they believe the job will complete quickly. And watch for the Status value to change.
  • Ended – This status indicates the batch job has completed. Typically this is seen when jobs are setup to run a single time. Batch jobs that are setup to run on a recurrence will change back to a status of ‘Waiting‘ after they have finished a particular run. However, if there is an ‘End Date‘ on the recurrence, and that has been reached, the Status will change to ‘Ended‘. Note: This status can be shown, even when tasks within a batch job may have errors. This just indicates that the overall batch job completed.
  • Error – Indicates the batch job failed to finish due to an error.
  • Cancelling – Indicates a user has manually selected to ‘Cancel’ a currently executing batch job. This is sometimes done when a job is running too long, and a user wishes to cancel it.
  • Withhold – Indicates that the batch job is ‘on hold’ and will not be run. A user would need to change the status to ‘Waiting‘ in order for it to be run again.

Changing A Batch Job Status

Before explaining why a user might want to change the status of a batch job, I will explain the steps.

First, on the ‘Batch Jobs’ form, select the batch job record. Secondly, click the ‘Change status’ button. Thirdly, in the dialog that opens, select a new status. Finally, click the ‘Ok’ button.

Change Batch Job Status

Typically, there are roughly four scenarios where a user needs to change the status of a batch job.

  1. A user wants to pause a recurring batch job from running. Click the ‘Change status‘ button and set the status from ‘Waiting‘ to ‘Withhold‘. Perhaps the process is causing performance issues, and the time needs to be changed. Or, data setup needs to be changed in order for the process to run successfully.
  2. A user wants to retry a batch job that currently has a status of ‘Error‘. Click the ‘Change status‘ button and set the status from ‘Error‘ to ‘Waiting‘. Perhaps the user believes they have fixed the data that was causing the error. And they want to try again.
  3. A job has run in the past, and completed with a status of ‘Ended’. Now, the user wants to run the same batch job with the same parameters again. Click the ‘Change status’ button an set the status from ‘Ended‘ to ‘Waiting‘. This saves the user time from having to setup and configure the batch job parameters again.
  4. An existing batch job has a status of ‘Executing‘, but it is never finishing. Click the ‘Change status‘ button and set the status to ‘Cancelling‘. As a result, cancelling a job can take a long time to roll back the process. So do so with caution.

Additionally, please see Microsoft’s documentation on how to change the status of a batch job.

Create A recurrence

When a batch is first created, click the recurrence button on the dialog form to configure the process to run more than once, and on a schedule.

First, set the ‘Start date‘ and ‘Start time‘ that the batch job should run. This is the initial date and time. However, if the job is setup to run more than once, this date and time will be used as a basis for any future runs.

To explain, in the below screenshot I have defined the recurrence to run the batch job once every 1 days. Because the first time it runs is at 11pm, and wait time is a full day, the job will run every day at 11pm.

Next, set the time zone.

Then, either set the job to run with ‘No end date‘, or ‘End after‘ a certain number of times, or ‘End by‘ a specified date.

Lastly, set the ‘Recurrence pattern‘, and the related parameters that show based on which option you select.

Finally, click the ‘Ok‘ button.

Manage The Recurrence

Another way to manage D365 batch jobs is to manage the recurrence. Often times the initial recurrence setup needs to be changed. Perhaps the frequency of how often the job runs needs to be changed.

After the batch job is created, go to the ‘Batch jobs’ form. Then, find and select the batch job record. Lastly, click the Recurrence button.

The same ‘Define recurrence’ dialog form is shown. Make any needed modifications. Then, click the ‘Ok‘ button to save the changes.

Recurring Jobs Vs One-Time Jobs

In D365, when a batch job is configured to only run once, that batch job will be shown in the grid on the ‘Batch jobs’ form. After running the Status is set to ‘Ended‘. As a result, there can be many records in this grid with a status of ‘Ended‘. This is fine and expected. Ironically, other batch jobs can be setup to cleanup these records.

Additionally, batch jobs that are setup with a recurrence also have a record in the ‘Batch jobs‘ form grid. However, it can be a bit confusing, because each time that batch job run, there is not a new record created in the main grid. Instead, new records are added to a ‘Batch job history’ grid related to the main job that has the recurrence.

Batch Job History

In order to view each run of a batch job that has a recurrence, we need to look at the ‘Batch job history’ form.

First, navigate to the ‘Batch jobs’ form. Go to System administration>Inquiries>Batch jobs.

Second, select a record from the grid with a status of ‘Waiting’. When the status is set to ‘Waiting’ this indicates to us this is a job with a recurrence, and likely has a history.

Thirdly, click the ‘Batch job history’ button.

The ‘Batch job history’ form will open. A record will show in this grid every time this job has run.

Batch job history

The ‘Actual start date/time’ shows the date and time the job was run. Click on the header column of this field to change the sort to show the more recent records at the top of the grid.

Reviewing Errors

Reviewing each batch job for errors is part of learning to manage D365 batch jobs.

In my example, I can see that the value of the Status field is set to ‘Error’. This indicates that when the batch job ran at that time, it did not complete successfully.

In order to see more information, first, select a record with an ‘Error’ status. Second, click the ‘Log‘ button. Thirdly, click the ‘Message details’ link on the infolog that is shown.

Batch Log

Read the dialog that opens with the error information. This information should be used to help identify and resolve the error. When the error is related to a possible code issue, a developer should be consulted. In the case where the error is related to data setup or configuration, a functional expert should be consulted.

Take action to attempt to resolve the error. Then, after the batch job has run again, come back to the ‘Batch job history‘ form. Lastly, validate that in the latest run of the job, that the Status is now ‘Ended‘.

If the Status is still set to ‘Error‘, review the logs, take action, and repeat.

At the present time, I will not try to cover various troubleshooting techniques for investigating errors with batch jobs.

Batch Job Alerts

Instead of always proactively monitoring batch jobs, Alerts can be setup to help manage D365 batch jobs. Batch job alerts can be configured to inform someone when a batch job ends, ends in error, or is cancelled. This way, D365 users can still ensure critical tasks complete without having to actively wait for them to finish.

Batch alerts can be setup when a user first creates a D365 batch job. Additionally, they can be setup or changed on the ‘Batch jobs’ form.

First, go to System administration>Inquires>Batch jobs.

Secondly, select a batch job record from the grid that you wish to setup Alerts for.

Thirdly, click the ‘Alerts’ button.

Fourthly, in the dialog form that is shown, specify which events you wish to monitor for this batch job. Additionally, specify if the alerts should show as pop-up notifications for your user. Or, if an email should be sent to a specified email address. Before configuring an email, ensure that the email parameters are properly configured by going to System administration>Setup>Email>Email parameters.

Batch Alerts

Finally click the ‘Ok‘ button to save the Alert setup.

Conclusion

There is a lot to know in order to manage D365 batch jobs. In this article, you learned many things to start. You learned how to find batch jobs setup in the system. Understand what the Status of the batch job means, and how to change it. Manage and change the recurrence on batch jobs. Investigate error messages on specific runs under the Batch job history form. And lastly, setup alerts to keep informed on the status of critical batch jobs.

There is still a lot more to know about batch jobs. And I look forward to continuing to teach about this very important topic.

Peter Ramer
Peter Ramer is a part of the Managed Application Services team at RSM working on Microsoft Dynamics 365. He focuses on the Retail and Commerce industries. When he is not solving problems and finding ways to accelerate his clients' business, he enjoys time with his three kids and amazing wife.

Share this:

3 thoughts on “How To Manage D365 Batch Jobs

Add yours

  1. Hi Peter, I’m struggling to find a way to promote batch jobs between environments. Would you mind pointing me in the right direction please?

    Thanks

    1. Typically you would just set them up again in the new environment with the same parameters and recurrence.
      So, perhaps you test out a job in your test or stage environment. Then set up the same batch job in production. From there you can take a backup of prod and restore the database from prod to stage then to a test or dev environment if you want to go that direction.
      But I don’t believe there is a way to export and reimport a list of batch jobs from one environment to another.

Leave a Reply

Your email address will not be published. Required fields are marked *

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑