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 468

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.

  • Suggested answer
    Vaishnavi J Profile Picture
    3,058 on at
    RE: Prevent deletion of customer accounts in Business Central?

    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

  • BCgs Profile Picture
    468 on at
    RE: Prevent deletion of customer accounts in Business Central?

    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,058 on at
    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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

#1
YUN ZHU Profile Picture

YUN ZHU 505 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 400

#3
Sagar Dangar, MCP Profile Picture

Sagar Dangar, MCP 384

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans