function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rahularorarahularora 

filtering users in apex code(Class) on users license type

Hi,

 

I have a requirement to filter users on the basis of user's license type.

I am able to access profile license type field in apex explorer but while using the same field in system log or apex class, it throws an error "no such fields on prfile"

kindly help

Best Answer chosen by Admin (Salesforce Developers) 
hisrinuhisrinu

Will this helps you?

 

integer u = [select count() from user where profile.UserLicense.Name = 'salesforce' and isactive = true];

 

I am not able to retrieve the licence type but I could filter it out users by licence type

All Answers

miha198206miha198206

Hi,

 

Try this:

 

 

[Select u.UserType, u.Name From User u WHERE u.UserType = 'Standard']

 

 

 

 

hisrinuhisrinu

Will this helps you?

 

integer u = [select count() from user where profile.UserLicense.Name = 'salesforce' and isactive = true];

 

I am not able to retrieve the licence type but I could filter it out users by licence type

This was selected as the best answer