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
Jason wang 29Jason wang 29 

I want to find specific license user!

I want to create a new user which license is salesforce. But the license was all used.  Also can`t see the salesforce license user in Setup>Users page.How to find it?
Best Answer chosen by Jason wang 29
GovindarajGovindaraj
Hi Jason,

You can use below SOQL query to find the users having Salesforce license.
Select Id, Name From User Where Profile.UserLicense.Name = 'Salesforce'
Thanks,
Govindaraj.S

All Answers

GovindarajGovindaraj
Hi Jason,

You can use below SOQL query to find the users having Salesforce license.
Select Id, Name From User Where Profile.UserLicense.Name = 'Salesforce'
Thanks,
Govindaraj.S
This was selected as the best answer
Ajay K DubediAjay K Dubedi
Hi Jason,

Following code helpful for you:
Map<Id,Profile> profileIds = new Map<id,profile>([SELECT Id,UserLicenseId FROM Profile where UserLicenseId  in (SELECT Id FROM UserLicense where name ='Salesforce')]);

List<user> standardProfileUsers = [select id from user where profileId in:profileIds.Keyset()];
system.debug('standardProfileUsers->'+standardProfileUsers);

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi