DataPerCompany change by code

Hello professionals,

Is it possible change table property DataPerCompany programmatically?

I need it because I have huge list of tables that are going to be shared between companies, but manually do that is job for a robot ;).

Maybe any other suggestions how to automate that process?

NAV 2009

Thank you.

Not unless you want to build your own C/AL parser to change it within the text files. Generally data per company is not the best idea, so you may want to look into other options to synchronize the code between the companies. There is a lot of discussion on the topic.

Hi Matt,

I have a similar problem, I want to change for example “Currency” for all the 8 companies at the same time, in this case will be good idea change the Table of Currency, to Data per Company because now is in Data per company

Oh you are scaring me Patricia… a huge list of tables? Who came up with that list? Did you talk to your partner about this?

You can’t just change that property without also considering the implications of what you are doing. As I said in another similar question by you, you can SEE the data in all companies, but you can also CHANGE the data in all companies, and data only gets VALIDATED in the one that you are logged in.

For example, let’s say you share the Item table. Let’s say in company A someone sets the Base unit of measure to EACH. For this to work, you need a record in the “Item Unit of Measure” table. If you don’t also share the Item Unit of Measure table, you will only be able to see the record in company A, and in Company B you can’t post a transaction against that unit of measure. Let’s say someone posts a transaction for EACH in company A. Let’s say someone in company B then decides to set the unit to BOX. The validation is not going to stop that user, because in company B there are no transactions. In company A meanwhile, you can’t be sure what is the right value. Then you have Variants, cross references, purchase prices, sales prices, my gosh there are so many tables you need to think about.

This is just a little bit of the potential DataPerCompany problems you can run into. You will need to take care of which company owns the data, you need to add logic to validation to check other company data, there are SO MANY things that can go wrong.

My point is, you cannot just start sharing a long list of tables, there is a LOT more to it than that.