Today, I would like to talk about a simple topic, how to automatically delete completely invoiced documents in Business Central.
First of all, the following descriptions are based on invoiced sales orders, and the same goes for other documents.
As you might know, in Business Central, after posting a sales invoice from the sales order page, the system will delete the completely invoiced sales order.
In case a sales invoice is created from the sales invoice page and use Get Shipment Lines functionality to do invoicing, the system will not delete the completely invoiced sales order.
So, what should you do if your process includes the above two operations and you do not want the invoiced orders to remain in the system?
It’s quite simple. In addition to manually deleting each order, in Business Central, you can delete invoiced documents with a batch job, such as Delete Invoiced Sales Orders.
You can find them in Tell me,
You can go and run it manually once a day, or once a week, but this can take quite a bit of time if it’s not just sales orders, but other things like purchase orders, service orders, blanket orders, etc.
So can it run automatically?
This time we are going to use the powerful task feature of Business Central, Job Queue.
Job queues in Business Central enable users to schedule and run specific Reports and Codeunits. You can set jobs to run one time, or on a recurring basis. For example, you might want to run the Salesperson * Sales Statistics report weekly, to track sales by salesperson each week, or you might want to run the Delegate Approval Requests codeunit daily, to prevent documents from piling up or otherwise block the workflow.
Choose the Tell Me icon, enter Job Queue Entries, and then choose the related link.
The Job Queue Entries page lists all existing jobs.
You need to specify information about the type of object you want to run, such as a Report or Codeunit, and the name and object ID of the object that you want to run.
This time the Object Type is Report and the Object ID is 299 (Delete Invoiced Sales Orders).
You can also add Report Parameters to specify the behavior of the job queue entry.
For example, delete only the invoiced sales orders with Sell-to Customer No. 40000.
The next important setting is the Recurrence, for example, runs at 3:00:00 PM every day.
You can also specify the date formula that is used to calculate the next time the recurring job queue entry will run. If you use a date formula, all other recurrence settings are cleared.
After you entered information such as parameters, time and date, recurrence, choose Process -> Set Status to Ready.
The Job Queue setting is complete.
Isn’t it so convenient?😃 Give it a try.
1. The user must have permission to run the particular report or codeunit, or an error will be returned when the job queue is run.
2. The following table describes the values of the Status field.
|Ready||Indicates that the job queue entry is ready to be run.|
|In Process||Indicates that the job queue entry is in process. This field is updated while the job queue is running.|
|On Hold||Default. Indicates the status of the job queue entry when it is created. Choose the Set Status to Ready action to change the status to Ready. Choose the Set On Hold or Suspend actions to change the status back to On Hold.|
|Error||Indicates that there is an error. Choose Show Error to see the error message.|
|Finished||Indicates that the job queue entry is complete.|
3. The Report ID and Name (As of 2021/08/11 BC18.3)
|Object ID||Object Name||Caption|
|291||Delete Invd Blnkt Sales Orders||Delete Invoiced Blanket Sales Orders|
|299||Delete Invoiced Sales Orders||Delete Invoiced Sales Orders|
|491||Delete Invd Blnkt Purch Orders||Delete Invoiced Blanket Purchase Orders|
|499||Delete Invoiced Purch. Orders||Delete Invoiced Purchase Orders|
|5914||Delete Invoiced Service Orders||Delete Invoiced Service Orders|
|6651||Delete Invd Sales Ret. Orders||Delete Invoiced Sales Return Orders|
|6661||Delete Invd Purch. Ret. Orders||Delete Invoiced Purchase Return Orders|
|5755||Delete Registered Whse. Docs.||Delete Registered Warehouse Documents|
4. If you want to keep sales orders, you can use the standard archive feature.
Find more about Archive Documents in Microsoft Docs.
Find more about Use Job Queues to Schedule Tasks in Microsoft Docs.
Hope this will help.
Thanks for reading.