web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

(1) ShareShare
ReportReport
Posted on by 131

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)
  • Sohaib Cheema Profile Picture
    48,039 User Group Leader on at
    Delete the legal entities other than current business unit - Dynamics 365 F&O
    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.
  • Syed Amir Ali Profile Picture
    131 on at
    Delete the legal entities other than current business unit - Dynamics 365 F&O

    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
    48,039 User Group Leader on at
    Delete the legal entities other than current business unit - Dynamics 365 F&O
    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?
  • Suggested answer
    Adis Profile Picture
    5,576 Super User 2025 Season 2 on at
    Delete the legal entities other than current business unit - Dynamics 365 F&O
    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

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 868 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 836 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 661

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans