+ Start a Discussion
SurenderSurender 

How to get Chatter free users in salesforce

Hi,

 

We want to implement some functionality only for Chatter Free users.


when we create new user, User License has Chatter free and Salesforce picklist values.


But we didn't find User License field in the User object.


We need soql to get only Chatter free users in the Apex, can someone post it.

 

Thanks in Advance.. 

bob_buzzardbob_buzzard

You get at the license type via the UserLicenseId on the Profile record rather than the user record.

SurenderSurender

Hi,

 

I used below query for the same.

 

Select Name,ProfileId from User u where u.ProfileId in (Select p.UserLicenseId From Profile p where p.UserLicenseId in (Select u.Id From UserLicense u where Name like 'Chatter Free'))

 

But am getting errors.. can you please correct the above.

 

Thanks..

bob_buzzardbob_buzzard

You can't nest subselects like that, and you are also comparing the u.ProfileId to the p.UserLicenseId, which are ids for different sobject types.

 

The following works for me:

 

List<UserLicense> ulics=[Select u.Id From UserLicense u where Name like 'Chatter Free'];
List<User> users=[Select Name,ProfileId from User u where u.ProfileId in (Select Id From Profile p where p.UserLicenseId in :ulics)];