Virtual Company and Table Collection in Ax 2012

Share Data to many Companies in Ax 2012

 

How to move data from normal company to virtual company when you introduce virtual company in existing Ax implementation. 

Virtual Company:
Dynamics Ax stores data as per company in tables. But there might be occasions when you want to share data across companies, like country, state, zip codes data. This sharing of data is achieved by creating a virtual company and storing data in this virtual company. Normal companies are then configured to read/write data from this virtual company. The only purpose of virtual company is to share data across companies, you cannot log into this virtual company.

Before seeing how to do virtual company setup, I would like you to show another trick that can be used to share data across Ax. There is a property on Ax tables 
called "SaveDataPerCompany", you can use this property to save data globally in Ax. To share data set this property to "No".

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg61iOHK9H6bdLgKJxBprgP9Njz5ITJ_Tkkf8lSdRsCrvbNU1x9PAI62izDRDFhylsY3P7jqe5wOYbKjobpGVpLqJZ_oVThE0vyLwE10jCC7c7LNP9baz3twob7Yl6fWd1er9Te8DGJkRce/s1600/sharedtable.jpg


Note: This data is shared by all the companies in Ax. This option will delete DataAreaId field and default (DataAreaId, RecId) index from the table. If you want more control on shared data, like which companies can share and which can not then use virtual company. 

Virtual Company setup:




STEP 1: CREATE TABLE COLLECTION

Decide which tables you want to share and create a table collection for these functionally related tables. For example; if you want to share Global Address Book across companies then you can utilize the existing table collection "DirPartyCollection".
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaUmrGl2dF-7e24g6_W5W-BEDmonmDKMI7e8jsFcU1iteP9L59gadRcIVg9aExLrG5MHDxEe6069wTtATjDiclVAN4d-boUqJJiAibk-2RbqIUE9tqEV357kgAbbsRc5FsBZSz9kgaieJX/s1600/dirpartycollection2.jpg


To create a table collection, go to AOT\Data Dictionary\Table Collections and on right click select "New Table Collection", then just drag your required tables in this collection.

Step 2: Create Virtual Company, configure/attach normal companies and table collection
Create a virtual company that will hold the shared data for normal companies.
Note: Before doing the below steps, make sure you are the Ax administrator and the only user online.
1.               Go to Administration -- Setup -- Virtual company accounts, and create a virtual company.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1O18UBRc_YuSGNF3RBNTl7o_yHZfPBDUqzE-H_pI2DQhYXlJAGgUC1oUG5ZBu8gEHek5st5_oV7q63IWSVJTTaJNufrSH3jzs_3qEyq4D-VnO4wZnxlARQMZBNSsT4iLBO157cc6Mhsd8/s1600/virtualcompany1.jpg

2.               Decide which companies needs to share data and attach those normal companies with this virtual company.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRPa5Pe3gZA-SAj9-zTARa2glMEaCvpm5Ir-HOGc2HGxugMuGFM4oHS2RqaRPTPZ9lBOp8zMD0JIzhAmuBixjjyl8VYOWJOEAyrIEGFZyuDbIztwvb4FRqKp8LUZLdL0QIg_KnpF_R5xum/s1600/virtualcomapny2.jpg

3.               Attach the table collection with this virtual company.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeWrTTA51vV9PLR4sRcShATARJwBk-2lmfP1Ygwjt87SsLD9Gx8rH0hAYEKL43vFC0bqtiuFCeewXOUJVgcOM_om6huB0cSk_VnLvwVkOQ1ETM0nQPWhMUEUo2dZZpw_AciQkNj3JdFJa4/s1600/virtualcompany3.jpg


Your Ax client will re-start and you are done with setting up the virtual company account.

Now, when you have virtual company in place, all new data will be saved in this virtual company. Only companies attached to the virtual company can use this shared data. All other companies which are not attached will work normally, these companies will 
continue to read/write data as per company bases.

How to move existing data to virtual company?
When you setup a new virtual company, Ax does not move data 
automatically from normal company to virtual company. This is done by system administrator manually.

There are many ways to do this data move, but I will discuss only two approaches here.

Ax Import / Export:


This is standard Ax approach.
1.               Manually export existing normal company data from Ax.
2.               Remove duplicate records from this exported data set. 
3.               Delete exported data from normal companies.
4.               Import the exported data back in Ax, while logged into one of the participating companies. 
5.               Create records deleted in point 2 again in Ax using your logic. How you want to handle duplicate? For example, if you have customer 'Rah' in more than one normal company, what you want to do with this?
Direct SQL:

Use this approach if you have good knowledge about SQL queries and Ax table structures/relationships. Below are few points that will help you understand what to do and how to do.
·                  All Ax tables store data as per company unless otherwise specified. For this, Ax uses a special field called DataAreaId. In case of virtual company, it does not matter from which normal company you log-in, it is always the virtual company id which is stored in DataAreaId field of shared tables. 
·                  Ax also assigns a unique 64bit number to each record in table. For this, Ax uses a special field called RecId. This RecId is unique in the table and is generated by Ax when you insert a new record in Ax. It is not related to DataAreaId / Company.
·                  For unique records between all participating normal companies, update the DataAreaId to the virtual company id.
·                  For duplicate records, create them again in Ax using some Ax job or Ax import/export technique.

Attached below are some SQL queries that might help you moving the 
Global Address Book records from normal companies to the virtual company by changing the DataAreaId.


Comments

Popular posts from this blog

Write/ Read to Excel Sheet

Table Methods in Ax 2012

Financial Dimensions in AX 2012