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

Delete the legal entities other than current business unit - Dynamics 365 F&O

(4) ShareShare
ReportReport
Posted on by 205

Hi Experts,

We currently have two different legal entities operating within the same tenant. One of them now plans to separate its business and move to a new standalone D365FO tenant. The requirement is to remove the other legal entity’s records from the database before going live.

Is this feasible, or would you recommend an alternative best practice?

 

Thank you.

I have the same question (0)
  • Suggested answer
    Adis Profile Picture
    6,597 Super User 2026 Season 1 on at
    Hello,
     
    I am not sure if I got it correctly, but you want to remove in the new tenant the records from the other legal entity?
     
    In general, deleting records isnt possible or recommended, you can mess up a lot. The application doesnt allow it through the entity as posted transactions must not be deleted. You could maybe delete it on database level if you have access to it (on-prem), however, I wouldnt recommened it at all.
     
    The general approach would be to create a new legal entity in the new tenant and use data import\export framework to migrate data, like Items, projects, workers, beginning balances.
    If you have to check older data in detail, you have to either export the transactions from the first tenant, or you have to have access to the data.
     

    Kind regards, Adis

     

    If this helped, please mark it as "Verified" for others facing the same issue

    Keep in mind that it is possible to mark more than one answer as verified

  • Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at
    Technically you can delete it (using SysDatabaseTransDelete) but there questions of business/audit nature.
    1) Are you going to recreate and re-post the transactions that you are deleting in this Tenant, into the new Tenant? Or is it you will take the opening balances only to the new tenant?
    2) How you would reproduce the reports from old years, if you delete the data?
    3) Is no legal requirement demands to keep the financial data for X number of years?
    4) Do you have any inter-company transactions as of today between the two companies, on this tenant? 
    5) Are you producing any consolidated reports as of today? what is the relationship between the two companies?
    6) Is Master Data Shared between the two companies?
  • Syed Amir Ali Profile Picture
    205 on at

    Sohaib, I reviewed the SysDatabaseTransDelete class, but since it’s deprecated and doesn’t support running in batch, it doesn’t seem feasible for my scenario.
     

     

     

    Adis, To clarify, we currently have two companies, X and B, operating on the same Dynamics 365 instance. Company B has around 3–5 legal entities (B1, B2, B3, B4, B5). My requirement is to clean up and delete the data for Company X, which consists of two legal entities, X1 and X2.

    In short, I need to completely remove legal entities X1 and X2 from the database and then import the db file on the UAT to verify the operations. 



     
  • Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at
    Right, given the circumstances, if you reach to Microsoft, they may ask you to use the Data Archival solution, which is not perfect yet, but getting there. However I would recommend you to open a support call and ask Microsoft, what do they suggest in this case.
     
    Along with that, you may want to look at the custom solutions, as recently many people have been writing own custom SQL scripts, an example here: https://github.com/TrudAX/TRUDScripts/blob/master/Performance/Jobs/deleteCompany.txt
     
    In case of custom solution, you would need to be extra careful, e.g. by taking such steps
    1) doing it on non-pro first
    2) after doing it on the non-Prod, do full cycle testing (including inventory closing and years end closing etc.)
    3) once you are fully satisfied, you can think to apply the solution on Prod (again you cannot run the SQL on the production, and you would want to discuss this with Microsoft)
     
    You can also think about writing custom X++ logic that can run in batch and do the job.
  • Suggested answer
    Syed Haris Shah Profile Picture
    1,572 Super User 2026 Season 1 on at
     
    The good news is you have raised this while you still in UAT. That means you caught it at the perfect time, before go-live. If this request had come after production, it would have been like trying to unbake a cake. But since we are still in the test kitchen (UAT), we can adjust the recipe and bake two separate cakes one for each company, just in time for go-live. I would recommend approach for your case as:
    1. Deleting one Legal entity records is risky and unsupported. UAT is meant for testing anyway, it doesn’t need to be perfectly clean forever.
    2. Request Microsoft to provision a new tenant with UAT + Prod environments. This will serve as Company B’s clean system.
    3. Treat current UAT as migration source. Import into Company B’s new UAT. Run reconciliation and end-to-end testing
     
    If you find this answer helpful, please consider verifying the answer. 👍
     
    Regards,
    Syed Haris Shah
  • André Arnaud de Calavon Profile Picture
    303,730 Super User 2026 Season 1 on at
    Hi Syed Amir Ali,

    I can imagine you want to delete the legal entities, but there is no official support for this from Microsoft. The class SysDatabaseTransDelete is indeed deprecated for many years. When using this, it can perform incorrect deletes and it can miss tables. (Been there, done that). Any custom script can also corrupt the data in your environment in case you miss tables or delete the wrong records.
    Sohaib mentioned archiving, but this does by far not support all tables and you won't be able to delete the legal entities.
     
    You can also consider using security configuration to restrict access to the companies used for operation. In case there is a hard requirement, deleting data will be at your own risk.
     
     

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans