Announcements
Hello,
I know this question has been asked a lot before, but we need to delete a posted invoice or credit note in BC.
I also know that there are some partners extension able to delete posted documents/credit notes.
Microsoft documentation says it is not possible, but how those partners can achieve this goal using AL Code?
Thanks in advance.
Hi, you can refer to codeunit 80 "Sales-Post", an additional Permissions property is set, so the post data can be inserted, modified and deleted.
Hope this helps.
Thanks.
ZHU
Hi,
As per the compliance, you should reverse the transaction rather than delete. If you delete the posted document then there is no authenticity of data and standard ERP.
Regards
Amit Sharma
www.erpconsultors.com
Press Yes if information is reliable.
Hello,
sorry for the late answer.
You're all correct on how to delete an invoice in BC and you're also correct about all the legal and consistency aspects.
There are however some specific use cases where a document must be deleted because of a duplicated invoice number (I think this was a little glitch in BC). This specific problem was solved with an environment rollback by Microsoft.
Anyway, the suggested "native method" will delete the document, but not the transaction which cannot be deleted in BC (and for a good reason I may add).
However I found out that there are some extensions (by third party and maybe not exactly "approved") that can delete an invoice and all transactions associated with it (with some limits).
At this point I think those extensions are using some undocumented method because when I tried to delete a transaction, an error was raisen.
We will try the third party extensions suggested here, but we're still curious to know how they achieve that, even just for emergency cases.
Thanks.
Additional info.
I have now also tried to delete a purchase invoice. The problem is the same, BUT this time the documentation was correct "If you enter a date, posted purchase documents with a posting date on or after this date cannot be deleted"
So i tested one more time deletion of a posted credit note and this time it was possible to delete a purchase credit note if the date in the 'Purchase & Payables Setup' is HIGHER than the invoice date. I am 100% sure that it worked the other way around the first time I delete a posted credit note, so there may also be some kind of error in this date controlled logic.
Anyway the basic functionality to delete posted documents is corrupting data and it should be blocked!
W A R N I N G
Its not clear to me if you mean purchase or sales, but I have tested deletion of a purchase credit note and I got a problem, that you should know about.
I tested the function to delete by setting a date in the "Allow Document Deletion' before field - as described by andy4029.
I created a posted credit note and deleted it again. At first it looked fine - I was able to delete the credit note and it really does not exist in the list of posted credit notes.
BUT if I go to the vendor I first of all see that credit note is still included in the Balance and if I open the list with Vendor Ledger Entires, the credit note also exist there. The related G/L entries does also still exist. This is in my opinion all bad and I'm sure this is not what you wish to happen.
I admit I have only made one single with one scenario, but I would still say that Microsoft should remove the delete function, because the result is data inconsistency.
Also note that the documentation if you move the cursor over the label "Allow Document Deletion Before" is wrong. It says "If you enter a date, posted purchase documents with a posting date on or after this date cannot be deleted", but it is the other way around, so the "cannot" should be a "can".
Best regards
Thomas Madsen Nielsen
Hi, hope the following helps.
4 WAYS TO DELETE RECORDS FROM A TABLE
Thanks.
ZHU
Hi, as Andy said posted documents can be deleted.
But based on your question i assume you also want to delete the data in transaction table.
Technically that is not a complex operation but you need to do it carefully not to break the consistency of your finance data.
In some region, mine included, it is illegal to delete transactions that are already posted, so the right way to do it with correction posting.
If there really is a need to delete transactions i recommend you discuss that with your partner to make sure they can verify that it is really needed and assist you in doing that.
1. I am just wondering what is the business reason you need to delete it? Its always better to leave it and reverse it if needed rather than deleting it, or create other accounting entries.
2. Business Central actually allows deleting posted invoices and credit memos. Look at the 'Allow Document Deletion Before' field in the 'Purchase & Payables Setup' and 'Sales & Receivables Setup'
If you enter a date, posted purchase documents with a posting date on or after this date cannot be deleted, but documents with an earlier date can be deleted. However, I would not recommend this.
3. Other than a few restricted tables, any data in most tables can be deleted or modified without validation. For example, a free extension that does this: https://vld-nav.com/table-data-editor-for-bc of course keeping in mind I would not recommend doing this other than for special situations or reasons
André Arnaud de Cal...
294,219
Super User 2025 Season 1
Martin Dráb
232,980
Most Valuable Professional
nmaenpaa
101,158
Moderator