2

I am looking for a query like login users assigned Apps.

2 Answers 2

1

You can query all the Apps available and see which are accessible to the current user by checking the isAccessible field:

List<AppMenuItem> accessibleApps = new List<AppMenuItem>();
for(AppMenuItem app : [SELECT Name, Description, ApplicationId, SortOrder, UserSortOrder, isAccessible FROM AppMenuItem ORDER BY userSortOrder NULLS LAST, sortOrder NULLS LAST]) {
    if(app.isAccessible) {
        system.debug('Current User has access to: ' + app.Name);
        accessibleApps.add(app);
    }
}

More info here: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_appmenuitem.htm

0
0

The code in the other answer only shows apps for the current User.

If you want to check which Users have Access to which Apps, just make a small test class and run this code

@isTest
public static void testMethod01(){
    List<User> userList = [Select Id, name from User where isActive = true];
    for(User user :userList){
        System.runAs(user){
            for(AppMenuItem app : [SELECT Name, Description, ApplicationId, SortOrder, UserSortOrder, isAccessible 
                                   FROM AppMenuItem 
                                   ORDER BY userSortOrder NULLS LAST, sortOrder NULLS LAST]) {
                if(app.isAccessible) {
                    system.debug('User--' + user.Name + ' --- ' + app.Name);
                }
            }
        }
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .