web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Prevent deletion of customer accounts in Business Central?

(0) ShareShare
ReportReport
Posted on by 470

Is there a way to prevent the deletion of customer accounts on Business Central. As a rule we never delete any off and mark at closed to keep the historical reference.

Somehow an employee has accidently deleted some off as I have found some records on our website that are not on Business Central and want to prevent this from happening again.

I have the same question (0)
  • Suggested answer
    Vaishnavi J Profile Picture
    3,062 on at

    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

  • BCgs Profile Picture
    470 on at

    Do you have any further details on the "Create a Boolean field in user setup page" any instructions or tutorials would be great.

    The permissions are set as Super so I don't think I can override the permission set. It is only the deletion of customers we need to prevent

  • Suggested answer
    Vaishnavi J Profile Picture
    3,062 on at

    Hi

    Create a table extension of User Setup page

    1.

    tableextension 50001 UserSetupExt extends "User Setup"
    {
        fields
        {
            field(50000;"Allowed Deleteion"; Boolean)
            {
                Caption = 'Allowed Deletion';
                DataClassification = CustomerContent;
            }
    }
    }
    2. then create a page extension for the user setup page.
    pageextension 50002 UserSetupExt extends "User Setup"
    {
        layout
        {
            addlast(Control1)
            {
                field(Allowed Deletion; Rec.Allowed Deletion)
                {
                    ApplicationArea = All;
                    Caption = 'Allowed Deletion';
                }
            }
         }
    }
    3. Then use the codeunit object add the event subscriber OnDeleteEvent and the logic to check who can delete customer record or not.

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,468

#2
YUN ZHU Profile Picture

YUN ZHU 923 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans