Tuesday, January 31, 2012

Get the Current Active Company in Dynamics AX.


Hi,

To get the Current Logged In Company you can Use the curExt() function in AX.

Example :

static void curExtExample(Args _arg)
{
str CompanyId;
;

CompanyId = curExt();
Info(CompanyId);
}



You would also get the same result with below code as well.

static void curExtExample(Args _arg)
{
str CompanyId;
;

CompanyId = CompanyInfo::Find().DataAreaId;
Info(CompanyId);
}


Enjoy DAX!!!

3 comments:

  1. Hello Kuldeep,

    CompanyId = CompanyInfo::Find().DataAreaId will return the first record in CompanyInfo table. Most likely it will be DAT company. So it shouldn't be used to return the current active company. CompanyId = curExt() should be used instead.

    Thank you for your helpful post!

    ReplyDelete
  2. CompanyInfo::Find() returns only from current Company as it does:

    select firstonly CompanyInfo
    where CompanyInfo.DataArea == curext();

    ReplyDelete
  3. Hello! Discover the power of Microsoft Dynamics GP with our outstanding developers available for hire. In our company, we are proud to associate enterprises with highly qualified GP developers. Trust us to optimize your financial management processes and drive your business to success. >> go to site

    ReplyDelete

Thanks for your time reviewing this blog.