在Axe 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;
}
但是在2012年的Axe中,我没有CompanyDomainList表,如何获得用户有权访问的公司列表?
答案 0 :(得分:4)
用户和copmany信息保存在OMUserRoleOrganization
表格中。
UserId userId = curUserId();
CompanyInfo companyInfo;
OMUserRoleOrganization oMUserRoleOrganization;
container result;
while select companyInfo
exists join oMUserRoleOrganization
where oMUserRoleOrganization.OMInternalOrganization == companyInfo.RecId
&& oMUserRoleOrganization.User == userId
{
result += [companyInfo.Name, companyInfo.DataArea];
}
if (!result)
{
// no specific company for user --> all
while select companyInfo
{
result += [companyInfo.Name, companyInfo.DataArea];
}
}