BeyondERP.Newsletter
Menu

Job page · System administration

Batch job history clean-up.

A periodic job that deletes all batch job history entries older than a set number of days.

Business process
Administer system features
Menu item
action:BatchJobHistoryCleanupFast
Setup steps
1 on this page
Show what matters for
PAGE GUIDEWhat the page does and how to use it8 sections. Choose a role to highlight what matters to you.
Everyone

1What it is and why

What it isA periodic job that deletes all batch job history entries older than a set number of days.
What you do hereUse this periodic task to keep the batch history small, because too much history slows down later batch jobs.
ExampleFor example, Optimization advisor reports too many batch job history entries in BEAT; the administrator schedules Batch job history clean-up every night with History limit (days) set to 30, the low end of the 30 to 60 days Microsoft keeps in production.
Batch job history clean-up. page in Dynamics 365
The page in Dynamics 365. page title tab to open what to set or check
Functional consultant · Solution architect

2Where it fits

End user · Functional consultant

3How to do it

About the examples: Examples and screenshots in this guide use BEAT, a demo company in a Dynamics 365 test environment. Use your own company's codes and values instead of copying them.

When to run it

When to run itWhen the batch job history has grown enough to slow down batch jobs, for example when Optimization advisor reports too many batch job history entries.
How oftenRegularly, outside business hours, as Microsoft recommends. In production, Microsoft also cleans batch history on a 30 to 60 day retention.
Batch settingsRun it as a recurring batch job at night, with no other history cleanup scheduled at the same time.
What the output showsAll batch job history older than the history limit is gone, across every job. If history you still needed for an investigation disappeared, the history limit was set too short.

Source: Microsoft Learn

Setup steps on this page

Schedule the batch job history clean-up

Keep the batch job history small so it doesn't slow down later batch jobs.

Steps from Microsoft

  1. Go to System administration > Periodic tasks > Batch job history clean-up (the menu label ends with a period).
  2. In History limit (days), enter how many days of batch job history to keep. Every older entry is deleted from BatchJobHistory together with its BatchHistory and BatchConstraintsHistory records.
  3. Use this standard version, not the custom one, when you want to remove everything older than the limit; it is faster because it doesn't filter.
  4. Schedule it outside business hours and never start it while another history cleanup is running, because parallel runs can cause database deadlocks.
  5. Afterwards, open the batch job history and confirm that no entries older than the limit remain.

Source: Microsoft Learn

Fields on the page

FieldWhat it meansExample
History limit (days)How many days of batch job history to keep.Microsoft Learn 30
Run in the backgroundSchedule the clean-up as a recurring batch job outside business hours.Microsoft Learn

Common errors and fixes

MessageWhat to do
The clean-up ends with a database deadlockAnother history cleanup ran at the same time. Run history cleanups one after another, outside business hours. Microsoft Learn

Test checklist

  1. No batch job history entry is older than the history limit.
  2. History within the limit is still there.
  3. The cleanup job itself finished without errors or deadlocks.

Source: Microsoft Learn

Functional consultant

4Setup decisions

Setup stepRecommended value and whyDecision, common mistake and test
Schedule the batch job history clean-upA recurring night run of the standard version with a history limit your support team agrees, never in parallel with another history cleanupLearn: too much history slows future jobs; clean regularly outside business hours, and parallel history cleanups can deadlock. The standard version is faster because it doesn't filter.Which history clean-up runs routinely?Scheduling the standard and the custom clean-up at the same time; parallel runs can deadlock on the history tables.Test: History older than the limit is gone

Feature management and licence

Licence or add-inNo Feature management feature needs to be turned on for this page.

Microsoft Learn

Solution architect

5Design impact

Shared or per companyShared: the batch job history table has no company key, and this version deletes all history older than the limit, whatever company or user. Use the custom version to filter by company. Microsoft data model
Can it be undoneNo: Deleted batch job history can't be restored. Export or note any history you need before you run it. Microsoft Learn
If you change it laterRun history cleanups one at a time and outside business hours, because parallel runs can cause database deadlocks. Microsoft Learn
Technical architect

6Technical

Menu itemaction:BatchJobHistoryCleanupFast Checked in Dynamics 365
Developer

7Developer

Open it by URLhttps://<your-environment>/?mi=action:BatchJobHistoryCleanupFast
Data migrationLoad order: Batch job history clean-up has no data entity in Data management, so it can't be loaded from a file or a configuration template. It is a periodic job; schedule it again in each environment. The history itself can be read with the Batch jobs history entity, not loaded back.Checked in Dynamics 365
Everyone

8Sources