Hi,
To Get User Security Role's Organization in AX
i.e. To Get User's Assigned roles and its assigned Legal Entities.
e.g. below sample show how to get user Chia's System user roles assigned legal entities. (from OMUserRoleOrganization Table)
Create Query like below (only active users) and add job as below code
Create new Job and Run. it will popup to save CSV. In CSV Select First Column Data --> DATA Tab --> Text to column --> Delimited using Comma. it will provide detailed data in column.
static void Shyam_SecurityUserRoleOrganization(Args _args)
{
SecurityUserRole sur;
OMUserRoleOrganization oro;
SecurityRole sr;
CompanyInfo ci;
LabelId lid;
UserInfo ui;
CommaTextIo file;
container line;
CustTable custTable;
Dialog dialog = new Dialog("Dialog name");
DialogField dialogFileName;
str fileName;
str txt;
str srName;
Query qr = new Query(queryStr(Shyam_SecurityUserRoleOrganization));
QueryRun qrun = new QueryRun(qr);
dialogFileName = dialog.addField(extendedTypeStr(FilenameSave), "Save csv file","");
dialog.filenameLookupFilter(['csv','*.csv']);
if (dialog.run())
{
fileName = dialogFileName.value();
Winapi::createFile(fileName);
info(fileName);
}
#define.filename(fileName)
#File
file = new CommaTextIo(#filename, #io_write);
line =["User","Network Domain","Role","Legal Entity"];
file.writeExp(line);
while(qrun.next())
{
sur = qrun.get(tableNum(SecurityUserRole));
oro = qrun.get(tableNum(OMUserRoleOrganization));
sr =qrun.get(tableNum(SecurityRole));
ci =qrun.get(tableNum(CompanyInfo));
ui=qrun.get(tableNum(UserInfo));
lid =sr.name;
if(lid ==sr.name)
{
srName = SysLabel::labelId2String(sr.name, 'en-gb');
}
else
{
srName= sr.name ;
}
// info(strFmt("%1 - %2 - %3",sur.User,srName,ci.DataArea));
line =[ui.name,ui.networkDomain,srName,ci.DataArea];
file.writeExp(line);
}
}
0comserYin-shi Patrick Burrell https://wakelet.com/wake/A-BtMcOU29B6NCc4vKuZx
ReplyDeleterecalnide
lumcinriaga_Tucson Corey Pickell Adobe XD
ReplyDeleteAdobe Acrobat Pro DC
Adobe Photoshop
viarigsejee