Export (0) Print
Expand All

Retrieving the Current Company [AX 2012]

Updated: January 16, 2012

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

When adding code to User Controls, you may want to know the company that the user is accessing. A method in the ControlHelper class from the Microsoft.Dynamics.Framework.Portal.CommonControls namespace simplifies this process. To access this namespace, you must add the following reference to your code.

using Microsoft.Dynamics.Framework.Portal.CommonControls;

The GetCurrentSessionCompany method is a static method for the ControlHelper class. The method returns the current company for the Enterprise Portal session as an uppercase string value. The method requires that you supply the Session Object. The following example code for a User Control retrieves the current company and displays the value in a text box.

protected void GetCompany_Click(object sender, EventArgs e)
{
    CompanyTextBox.Text = ControlHelper.GetCurrentSessionCompany(AxSession);
}

Community Additions

ADD
Show:
© 2014 Microsoft