DAXSPOT

Tuesday, November 15, 2022

Accessing Data of other companies/Legal entities using X++

Hi,

In Microsoft Dynamics AX/D365 Finance and operation, users can setup multiple legal entities. By default in Microsoft Dynamics AX/D365 FO, all tables store data per company unless SaveDataPerCompany property is not changed to NO. By default value of property SaveDataPerCompany  = Yes.

Using crossCompany & changeCompany keyword, you can construct a query to retrieve all records, regardless of the company you are currently logged into. You can fetch the all the company records using keyword - crossCompany and function – changeCompany.


Change-Company:

static void main()

{

  CustTable custTable;

  changeCompany('INMF') 

  {

    custTable = null;

    while select custTable

    {

       //custTable of company 'INMF'.

    }

  }

}


Cross-Company:

static void main()

{

  CustTable custTable;

  while select crosscompany custTable

  {

      //custTable of all the companies

  }

}


Thank you,

No comments:

Post a Comment

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...