Axapta 如何在Ax 2012中获取公司用户访问列表?

Axapta 如何在Ax 2012中获取公司用户访问列表?,axapta,dynamics-ax-2012,x++,Axapta,Dynamics Ax 2012,X++,在Ax 2009中,要按用户获取公司列表,我可以通过以下方式获取: static container getAllCompanies() { Container companies; DataArea dataArea; CompanyDomainList companyDomainList; AccessRightsList accessRightsList; UserGroupList userGroupList; //se

在Ax 2009中,要按用户获取公司列表,我可以通过以下方式获取:

static container getAllCompanies()
{
     Container companies;
     DataArea dataArea;
     CompanyDomainList companyDomainList;
     AccessRightsList  accessRightsList;
    UserGroupList        userGroupList;


//select all the companies in which current user’s access level is higer than NoAccess
     while select id,name from DataArea
           Exists join companyDomainList
           where companyDomainList.companyId == dataArea.Id
           join accessRightsList
           where accessRightsList.domainId   ==  companyDomainList.domainId && accessRightsList.accessType > AccessType::NoAccess
           join userGroupList
           where userGroupList.groupId       == accessRightsList.groupId && userGroupList.userId == curuserid()
     {
          companies += [dataArea.name,dataArea.Id];
     }

     return companies;
}

但是在Ax 2012中,我没有CompanyDomainList表,如何获得用户有权访问的公司列表?

用户和公司的许多信息都保存在表中

UserId UserId=curUserId();
公司信息公司信息;
OMUserRoleOrganization OMUserRoleOrganization;
容器结果;
同时选择公司信息
存在加入oMUserRoleOrganization
其中oMUserRoleOrganization.OMInternalOrganization==companyInfo.RecId
&&oMUserRoleOrganization.User==userId
{
结果+=[companyInfo.Name,companyInfo.DataArea];
}
如果(!结果)
{
//没有用户-->所有的特定公司
同时选择公司信息
{
结果+=[companyInfo.Name,companyInfo.DataArea];
}
}