从AX 2012导出自定义angular色到Excel

我编写了一个导出AX附带的用户angular色的代码,但是已经分配的自定义angular色不被导出。 我正在做一个angular色的重新分配,我希望每个angular色都被列出来。 这是我做的第一个任务的代码。 谢谢。

static void exportSecurityRoles(Args _args) { SysExcelApplication xlsApplication; SysExcelWorkBooks xlsWorkBookCollection; SysExcelWorkBook xlsWorkBook; SysExcelWorkSheets xlsWorkSheetCollection; SysExcelWorkSheet xlsWorkSheet; SysExcelRange xlsRange; CustTable custTable; int row = 1; str fileName; SecurityRole securityRole; SecurityUserRole UserRole; SysUserInfo userInfo; OMUserRoleOrganization roleOrganization; OMInternalOrganization internalOrganization; ; //Filename fileName = "C:\\UserRoles.xlsx"; //Initialize Excel instance xlsApplication = SysExcelApplication::construct(); //Open Excel document //xlsApplication.visible(true); //Create Excel WorkBook and WorkSheet xlsWorkBookCollection = xlsApplication.workbooks(); xlsWorkBook = xlsWorkBookCollection.add(); xlsWorkSheetCollection = xlsWorkBook.worksheets(); xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1); //Excel columns captions xlsWorkSheet.cells().item(row,1).value("User Id"); xlsWorkSheet.cells().item(row,2).value("Role"); xlsWorkSheet.cells().item(row,3).value("Company"); row++; //Fill Excel with CustTable AccountNum and Name fields (only 20 records) while select ID from userInfo order by id asc outer join UserRole where UserRole.User == userInfo.Id outer join securityRole where securityRole.RecId == UserRole.SecurityRole outer join roleOrganization where roleOrganization.User == userInfo.Id && roleOrganization.SecurityRole == UserRole.SecurityRole outer join internalOrganization where internalOrganization.RecId == roleOrganization.OMInternalOrganization { xlsWorkSheet.cells().item(row,1).value( userInfo.Id); xlsWorkSheet.cells().item(row,2).value(SysLabel::labelId2String(securityRole.Name)); xlsWorkSheet.cells().item(row,3).value(internalOrganization.Name ? internalOrganization.Name : "All Company"); row++; } //Check whether the document already exists if(WinApi::fileExists(fileName)) WinApi::deleteFile(fileName); //Save Excel document xlsWorkbook.saveAs(fileName); //Open Excel document xlsApplication.visible(true); //Close Excel //xlsApplication.quit(); //xlsApplication.finalize(); }