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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Deleting Customer Records

(0) ShareShare
ReportReport
Posted on by

I need to create a function that deletes customer accounts and related data (contacts and addresses).

I tried using delete_from on the customer table but this still leaves the contacts table unaffected (with orphaned records)

I conjecture that perhaps I need to call the delete method on the table which should remove the related records, but I looked the delete actions on the table which do not seem to include contacts and addresses

Not sure the best path to take...perhaps delete using CustCustomerV3Entity entity?

Tanks in advance

I have the same question (0)
  • Suggested answer
    SouravDam Profile Picture
    11,730 on at

    Hi brianmaric,

    Would like to know, you are trying to delete the customer master records in test or production environment?

    Deleting master data in Production environment is not advisable as transactions may have already recorded which create impacts in financials.

    Again; if this is related to Production system, then better you can set those customer status "On hold" so that no transactions can be posted further.

    If this is in test environment and if transactions are already recorded against those master data, then you need to delete those transactions first (if there is no need to maintain transactions in test). Then system will allow you to delete customer master data.

    Best regards,
    Sourav Dam

    Kindly mark this thread 'Yes' if this is answered your query which may help other community members in this forum.

  • Suggested answer
    Satish Panwar Profile Picture
    14,671 Moderator on at

    Hi Brian,

    See delete options available through different means.

    community.dynamics.com/.../data-deletion-options-in-d365-finance-and-operations

    If you are writing this function in D365, based on your customer, first delete all associated contacts and then customer itself.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi brianmaric,

    Why don't you simply put the customer on hold for all transactions then you don't need to spend time thinking about coding (and potentially related problems) or any other kinds of workaround.

    Just try to use what we have available in the standard solution ;-)

    Best regards,

    Ludwig

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Contacts and addresses are related to Party, not directly to the customer. If you delete the customer from UI, does it then delete the contacts and addresses? If yes, look at the code that the system runs when customer is deleted via UI.

    However if the customer is already used in some transactions, it should not be deleted (and can't be deleted via UI).

  • Suggested answer
    Ehab_altammam Profile Picture
    150 on at

    Hi Brianmaric,

    the std code to delete the customer is deleleting the party table which will delete the contacts .. see below line from the delete method in the  cust table

    pastedimage1575810741348v1.png

    so would suggest to use the std delete method . 

    and you can use the validate delete in the table as well to check if there are any transactions ( its checking  only the sales table  ) .

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    303,669 Super User 2026 Season 1 on at

    There is a setting in the global address book parameters which manages if an orphaned party record (with related contact details) will be deleted or not. The code highlighted by Ehab is first looking at this parameter.

  • brianmaric Profile Picture
    on at

    I tried calling this method.  It only deletes the record from the DirPartyTable the contacts and addresses are still there.

    Fyi...we are involved in a data migration project.   We are not going to use this code in Prod.  We are using it in the UAT so that we can clear the data and re-import using our data integration tools.

    looks like i need delete the data one table at a time.  The default behavior is to hang on to addresses and contacts even though the Customer is deleted.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans