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!!!
Hello Kuldeep,
ReplyDeleteCompanyId = 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!
CompanyInfo::Find() returns only from current Company as it does:
ReplyDeleteselect firstonly CompanyInfo
where CompanyInfo.DataArea == curext();