Wednesday, 10 October 2018
List Security Roles in AX2012 to Excel
static void SecurityCreateExcelDocument(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
int row = 1;
str fileName;
SecurityUserRole _SecurityUserRole;
SecurityRoleTaskGrant _SecurityRoleTaskGrant;
SecurityTask _SecurityTask;
SecurityRole _SecurityRole;
UserInfo _UserInfo;
fileName = "D:\\Security.xlsx";
xlsApplication = SysExcelApplication::construct();
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBook = xlsWorkBookCollection.add();
xlsWorkSheetCollection = xlsWorkBook.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
xlsWorkSheet.cells().item(row,1).value("User Role");
xlsWorkSheet.cells().item(row,2).value("User Id");
xlsWorkSheet.cells().item(row,3).value("Legal Entity");
row++;
while select _UserInfo
{
while select _SecurityUserRole where _SecurityUserRole.User==_UserInfo.id
{
while select _SecurityRole where _SecurityRole.RecId==_SecurityUserRole.SecurityRole
{
xlsWorkSheet.cells().item(row,1).value(_SecurityRole.Name);
xlsWorkSheet.cells().item(row,2).value(_UserInfo.id);
xlsWorkSheet.cells().item(row,3).value(_UserInfo.company);
row++;
}
}
}
if(WinApi::fileExists(fileName))
{
WinApi::deleteFile(fileName);
}
xlsWorkbook.saveAs(fileName);
xlsApplication.visible(true);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment