How to find Salesforce Profiles with No Users on it

by - 8:51 PM

How to find a Salesforce profile which has no user
I was asked to figure out a way where we can find out the list of the profile which do not have any assigned user, this sounds little tricky on paper but in reality, this isn't tricky at all. Here is small piece of Apex code that helps you out doing this 

If you read carefully attached are steps 

1. Query for grabbing list of all profiles
2. Query for grabbling list of all user
3. Generate a list of Profile type to collect - 'profiles with no user' 
4. Iterate to all profile - set up a flag as false

      for each profile ( if user.profileId == - based on Salesforce schema (if user.profileId matches with original profile id)

5.  else if not - add that profile to our custom list 
6. Display list of profile 

You May Also Like