RE: Prevent deletion of customer accounts in Business Central?
Hi,
there are 2 ways to do so.
1. Restrict the users to delete the customer record via code.
Create a Boolean field in user setup page. if the boolean is checked mark then the user is allowed to delete.
you can use event subscriber
[EventSubscriber(ObjectType::Page, Page::"Customer Card", 'OnDeleteRecordEvent', '',true , true)]
local procedure DeleteCustomerCheck(var Rec: Record Customer)
var
Rec_UserSetup: Record "User Setup";
begin
if Rec.IsTemporary then
exit;
Rec_UserSetup.GET(USERID);
if not Rec_UserSetup.Allowed Deletion then
Error('You do not have permission to delete the Customer.');
end;
2. Or you can remove the delete permission from the permission sets given to the users.
If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much