How to prohibit users from deleting master data or posted documents in Dynamics 365 Business Central

Dynamics 365 Business Central

Hello everyone.
This time I want to talk about a requirement of prohibiting users from deleting master data and posted documents.
As we know, data in Business Central are classified roughly into three types. Master Data (Including setting data), Data Before Posting, Data After Posting.
For example:
Master Data: Customer Master, Vendor Master, Payment Method, etc.
Data Before Posting: Sales Orders, Purchase Orders, General Journal, etc.
Data After Posting: Posted Sales Invoice, Posted Purchase Invoice, General Ledger Entries, etc.

Among these data, except the Ledger Entries data, are allowed to be deleted in Business Central.
Customer:

Posted Sales Invoice:

Therefore, when customers want to ensure data integrity, BC users are not allowed to delete the Master Data and Posted Data.
So how to do it in Business Central.
Let me share two ways in this blog.

1. Add a new Permission Set to prevent users from having delete permissions. (NO Customize)

Open “Permission Sets” page.

Add a new Permission Set without “Delete Permission”.
For Example:
Customer Table:

Sales Invoice Header Table and Sales Invoice Line Table.

Assign the “Permission Set” to users.

Button will turn gray after users logs in, and the users cannot click the delete button.

2. Error while deleting (Customize)

For base pages in Business Central, you can’t able to modify the “InsertAllowed”, “ModifyAllowed” and “DeleteAllowed” properties by Page Extension. So, if you don’t want to create a new page, you can only use trigger to limit it.
For Example:
OnDeleteRecord() trigger on the page.

When deleting.

You can also use the OnDelete() trigger of the table or the Event Sub of the Codeunit. And add some conditions to determine whether it can be deleted.

PS:
For Posted Data, like Posted Sales Invoice, you can clear the value in the “Allow Document Deletion Before” field on the “Sales & Receivables Setup” page. Then posted sales documents can not be deleted.

Allow Document Deletion Before
Specifies if and when posted sales documents can be deleted. If you enter a date, posted sales documents with a posting date on or after this date cannot be deleted.

Purchase Documents is same as Sales.

I prefer the first method because it does not need customization. 😀

Hope this will help.
Thanks.

コメント

タイトルとURLをコピーしました