A customer had a question about the document routing history cleanup job that stopped working. After some debugging, they found that the job was created by a user who left the company, and their account was no longer active. This raised the question of how the job was created and how to use a different user to set it up. We did some research, and here’s what we found.
Intro
When you print a report using the printer, the print job goes through document routing (DRA). The document is temporarily stored in Azure Blob storage and related information is stored in Azure storage table and in D365FO table. Over time, this can use up a lot of space. As an optimization, Microsoft created a batch job that cleans up the data after a certain time, based on the settings you configure.
Files on Azure Blob storage
Table on Azure Table storage
Table in D365FO database
If needed, you can also access this table directly through F&O (Models > Common > Inquiries > Inquiries > Document routing status).
About batch job - Document routing history cleanup
The batch job for this task is called ‘Document Routing History Cleanup.’ By default, it runs daily from the time it is created, but this schedule can be changed if needed. The person who created the batch job is the task owner. We will later find out who created it and how, but even if the batch job was created by someone else, there is an option to change the user who runs the batch job. It is recommended that is runs by a service or admin account, not by an ordinary user.
How to Configure Parameters for the Job
- Standard SSRS Printer Print Destination
As provided in Microsoft documentation, you can find all the necessary information here. - Docentric Printer Print Destination
For Docentric, we’ve made an easy-to-use interface in the Docentric AX parameters under the “Document Routing” section that is just a simpler GUI for standard setup. In the “Document Routing History Cleanup” settings, you can:- Enable or disable the creation of a batch job (though disabling it will not stop the task itself; it will simply not recreate the batch job if one does not exist). It applies only to Docentric printer print destinations, when printing to standard print destination it will be always enabled
- Set the Retention Days and Retention Hours properties; this is a single property that can be entered in either days or hours.
- Retention Days: Specifies how many days to keep a document before it gets deleted or archived.
- Retention Hours: Specifies how many hours to keep a document before it is removed or archived. This helps you manage how long data is stored.
How the Batch Job Is Created Automatically
By default, a batch job is automatically created when a user prints a document using the printer’s print destination. The user becomes both the owner and the executor of the task. This automatic batch task creation cannot be directly disabled or enabled in the standard SSRS pipeline. However, in Docentric, you can control this behavior by toggling the “Document Routing History Cleanup” flag within the Docentric parameters.
Each time you print using the printer’s print destination through the routing engine, the system checks if the batch job already exists. If it doesn’t, a new batch job is created. Even if a batch job is deleted, printing the document again will generate a new batch job.
How to Create the Batch Job Manually
If you what to recreate the batch job without printing to the printer, you can manually invoke the following URL (you must have admin rights):
https://<your_environment_url>/?mi=SysClassRunner&cls=DocumentRoutingHistoryCleanupBatchJob
The owner and the person who will run this URL will be the user who created the batch job, meaning they are both the owner and the executor of the batch job.
Conclusion
This batch job is important for keeping your system running smoothly. If it stops, it can use up a lot of space, which might slow down your system or increase storage costs. It’s a good idea to check who owns and runs the batch job. If it’s not the right user, you can either change the user directly in the batch job or create a new batch job. It’s up to you to decide.