Friday 7 October 2016

ChangeCompany in Microsoft dynamics ax 2012.


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

changeCompany ( Expression ) Statement


static void changeCompany(Args _arg)
{
    VendTable vendTable;
    ;

    // Assume that you are running in company 'Test'.
    changeCompany('Test1') // Default company is now 'Test1'.
    {
        vendTable = null;
        while select vendTable
        {
            // vendTable is now selected in company 'Test1'.
        }
    }
    // Default company is again set back to 'Test'.

    changeCompany('Test2') // Default company is now 'Test2'.
    {
 
        // Clear vendTable to let the select work
        // on the new default company.
        vendTable = null;
 

        while select vendTable
        {
            // vendTable is now selected in company 'Test2'.
        }
    }
    // Default company is again 'Test'.
}

No comments:

Post a Comment