We  can enable the change log in Dynamics NAV so we have a history of activities. The change log collects all changes that are made to the table so we can track it.

We are good so far but the issue arises when we have millions entries in the system. It not only takes up the memory space of the server but also affects the performance. Hence, I’ve customised a job for deleting change log entries.

  • This job only deletes entries less than 60 days old. (i.e If today is 08/11/2019 then data to be saved will be till 08/09/2019 , beyond it will be deleted)
  • This job is set up to run only on Saturdays (non-working day ) at 10 p.m (this can be changed according to your requirement).
  • As we already have millions of entries my job will delete last 10 days entries every Saturday until it reaches the last 60 days (Reason for 10 days interval  is that we can have logs of thousands for each day)

Pre-requisites :

Microsoft Dynamics NAV 2018


  • Open the Development Environment of NAV and navigate to report no 510 – Change log Delete. This is a built in report by Microsoft which requires user to manually fill in the dates to delete the logs.
  • Open the report 510 in Design mode and comment the code on Pre-report
  • On Pre-Data Item trigger enter the code as below


Explanation of the code:

  1. The first entry of Change log entry table is checked if its less than the last 60 days from today
  2. First entry is stored in a variable FirstDate. 10 days are added to FirstDate and stored in another variable TenDate
  3. TenDate is checked if its less than the 60 days from today’s date
  4. Change log Entry is filtered to Date and time less than TenDate to be deleted
  5. OnAfterGetRecord Trigger, add DELETE code to delete the entries.


  • Open the Role Tailored Client (RTC) and type job queue entries in the search bar


  • Click on New and select Object Type to Run as Report, Object ID to run as 510, enable Run on Saturdays and enter Starting time as 22:00:00 (10 p.m.) and No. of Minutes as 10080( 60*24*7) to run once a week


Please click on the below link to download the code

Change Log – Delete

Happy Weekend!