Click to Rate and Give Feedback
MSDN
MSDN Library
Microsoft Dynamics
Best Practices
Design Patterns
 Change Company Design Pattern [AX 2...
Collapse All/Expand All Collapse All
Microsoft Dynamics AX 2012
Change Company Design Pattern [AX 2012]

Updated: March 15, 2011

Applies To: Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

A change to the design pattern of a large company is often the result of it being split into several legal entities. The Microsoft Dynamics AX development environment supports this by using the changeCompany function in X++.

The changeCompany statement is used to alter the database settings to another (separate) company. The syntax of the statement is:

changeCompany ( Expression ) Statement

Expression is a string that defines which company is to be used. The statement is executed on the new company. The following example shows how to use this statement.

static void main()
{
    CustTable custTable;
    ;
 
    // Assume that you are running in company 'aaa'.
    changeCompany('bbb') // Default company is now 'bbb'.
    {
        custTable = null;
        while select custTable
        {
            // custTable is now selected in company 'bbb'.
        }
    }
    // Default company is again set back to 'aaa'.
 
    changeCompany('ccc') // Default company is now 'ccc'.
    {
    
        // Clear custTable to let the select work
        // on the new default company.
        custTable = null;
    
 
        while select custTable
        {
            // custTable is now selected in company 'ccc'.
        }
    }
    // Default company is again 'aaa'.
}

The changeCompany keyword is useful in scenarios where the crossCompany keyword is used. For more information, see Cross-Company Data Modification Using X++.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker