ARIS Community - We Love BPM

ARIS Script

ahmad.theeb's picture
by Faris adel in Reports & Macros posted on 2017-06-22

Hi all ,

please help me , i want to show report contain all user for all databases .

i do it manualy using  ArisData.openDatabase(nameofDataBase) , but i want all database

 

Best Regards ,  

5357 Views
0 Likes
5 Comments
Tags
There are no attachments
Tricarico Romain posted on 2017-06-22

Hi Ahmad,

I suggest to use the UMC component :

var umc = Context.getComponent("UMC");

var umcUsers = umc.getAllUsers();

 

Best Regards.

Faris adel posted on 2017-06-22

hi Tricarico Romain ,

when excute code give me an error on getAllUsers()  and saied it is not exist

Best Regards ,

Florian Rese posted on 2017-06-23

Hi Ahmad,

below are a few options, which all work for me, when trying to retrieve the list of all users (including the one from Tricarico, which is working for me). There are probably better/ more convenient ways to achieve, what you are looking for, but all 4 of these options work for me:

var database_list = ArisData.getSelectedDatabases(); //database(s) selected for the report

function main(){
    if (database_list.length > 0) {
        for (var i = 0 ; i < database_list.length; i++ ){
            var current_database = database_list[i];
            var user_list = current_database.AssignedUsers();
            user_list = __sort(user_list, Constants.SORT_TYPE, Constants.AT_NAME, Constants.SORT_NONE, g_nloc);
            
            var user_list_2 = current_database.UserList();
            user_list_2 = __sort(user_list, Constants.SORT_TYPE, Constants.AT_NAME, Constants.SORT_NONE, g_nloc);
            
            var UMC         = Context.getComponent("UMC");
            var user_list_3 = UMC.getAllUsers().toArray();
            user_list_3 = __sort(user_list, Constants.SORT_TYPE, Constants.AT_NAME, Constants.SORT_NONE, g_nloc);
            
            var UserGroupsList = current_database.UserGroupList();
            var user_list_4 = [];
            var counter = 0;
            var users_per_group =[];
            var max_users = 0;
            for (var j = 0; j < UserGroupsList.length; j++){
                var current_user_group = UserGroupsList[j];
                users_per_group[j] = [current_user_group];
                var current_user_group_users = current_user_group.UserList();
                for (var k = 0; k < current_user_group_users.length; k++){
                    user_list_4[k+counter] = current_user_group_users[k];
                    users_per_group[j][k] = current_user_group_users[k];
                    if (current_user_group_users.length > max_users){
                        max_users = current_user_group_users.length;
                    }
                }
                counter = counter + current_user_group_users.length;
            }

Faris adel posted on 2017-06-26

Hi Florian Rese ,

thanks alot for trying to help me , but i faced problem that when the dialog is shown to select database(s) , if i select one of database then the array have 1 element but i select more then one of databases the array have no element , i no have idea about this problem

Best Regards ,

Sumeet Satwani posted on 2017-06-26

HI

 

You can try the below code, its gives the user names along with their groups:

 

var g_Output    = Context.createOutputObject();
var g_Locale    = 1033;
var UMC         = Context.getComponent("UMC");

main();

function main() {
    initializeOutput();
    g_Output.BeginTable(100, Constants.C_BLACK, Constants.C_TRANSPARENT,  Constants.FMT_LEFT | Constants.FMT_REPEAT_HEADER, 0)
   
    /*g_Output.TableRow();
    writeHeader(getString("REPORT_TITLE"), 7);
    g_Output.TableRow();
    writeDescription(getString("REPORT_DESCRIPTION"), 7);
    g_Output.TableRow(); */
    writeTableCell("");
    g_Output.TableRow();
   
    writeTableHeaderCell(getString("COLUMN_USERGROUP_NAME"), 40);
    //writeTableHeaderCell(getString("COLUMN_LICENSE_PRIVILEGES"), 40);
    //writeTableHeaderCell(getString("COLUMN_FUNCTION_PRIVILEGES"), 40);
    writeTableHeaderCell(getString("COLUMN_LAST_NAME"), 30);
    writeTableHeaderCell(getString("COLUMN_FIRST_NAME"), 30);
    //writeTableHeaderCell(getString("COLUMN_EMAIL_ADDRESS"), 50);
    writeTableHeaderCell(getString("COLUMN_USER_NAME"), 30);
   
    var selectedUsergroupNames = getSelectionList();
   
    var usergroups = UMC.getAllUsergroups();
   
    var isEvenCell = true;
   
    for(var i = 0 ; i < usergroups.size() ; i++) {
        isEvenCell = !isEvenCell;
        var usergroup = usergroups.get(i);
        var name = usergroup.getName();
       
        if(!selectedUsergroupNames.isEmpty() && !selectedUsergroupNames.contains(name)) {
            continue;
        }
       
        g_Output.TableRow();
       
        var licensePrivileges = UMC.getPrivilegesForUsergroup(usergroup, false, true);
        var functionPrivileges = UMC.getPrivilegesForUsergroup(usergroup, true, false);
        var assignedUsers = UMC.getAssignedUsersForUsergroup(usergroup);
       
        writeTableCell(name, 40, isEvenCell);
        var rows = assignedUsers.size();
        for(var j = 0 ; j < rows ; j++) {
            if(j != 0) {
                g_Output.TableRow();
                writeTableCell("", 40, isEvenCell);
            }
            if(assignedUsers.size() > j) {
                var user = assignedUsers.get(j);
                writeTableCell(user.getLastName(), 30, isEvenCell);
                writeTableCell(user.getFirstName(), 30, isEvenCell); 
              
                writeTableCell(user.getName(), 30, isEvenCell); 
            } else {
                writeTableCell("", 30, isEvenCell);  
                writeTableCell("", 30, isEvenCell);
              
                writeTableCell("", 30, isEvenCell);
            }
        }  
    }
    g_Output.WriteReport();
}