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
raj kiranraj kiran 

soql for total license used in SFDC

Hi All,

I am looking for soql which could fetch me all the license used for all inactive and active users in one shot. similar to displaying company license information in native SFDC environment.

I am working on displaying the license information on VF such that i can have my own custom activation and deactivation of users in organization.

Any light on this is greatly appreciated.
Grazitti TeamGrazitti Team
Hi Raj,

You might have to do this the old-fashioned way.
query the User object and group by User License!

--
Regards,
Grazitti Team
Web: www.grazitti.com
Email: sfdc@grazitti.com
Grazitti TeamGrazitti Team
or you can try following query:

select profile.UserLicense.name from user group by profile.UserLicense.name
raj kiranraj kiran
Grazitti Team,

Thanks for your quick reply. Your information was quite useful.

however i am looking for bit more elabartive soql which could fetch me all the license used in an organization with count like how it gets dispalyed in company inormation link in SFDC.

Please let me know how can u process ahead.!
 
Grazitti TeamGrazitti Team
So , do you want a count of license used in your salesforce instance?
sfdcdevsfdcdev
You can use UserLicense object to query TotalLicenses,UsedLicenses,Status,Name,etc..See below link for more details.

https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_userlicense.htm
raj kiranraj kiran
Grazitti Team,
Yes. count of licenses used and unused.

TotalLicenses,UsedLicenses fields are available on userobject yet they are not available for our developement purposes. NOt even read mode has been enabled on them.

Wondering if there is any workaround for it.
raj kiranraj kiran
sfdcdev,

Thanks for your reply.
  I am aware of this object acess, TotalLicenses,UsedLicenses are restricted even for view in SFDC environment for developers.

 
Richard ScottRichard Scott
When do you all anticipate that the TotalLicenses and UsesLicenses fields in the UserLicense object will be accessible via the API without joining the pilot program?  Can you reccomend a different way to get these metrics via the API?
Richard ScottRichard Scott
I ended up settling for a total licenses used count.  I achieved this by querying the profiles to determine the license assigned to the profile, licenses, and then users associated with each profile.  The end result was a count of users per license type.  I would still like to see TotalLicenses and UsedLicenses available via the API.  I upvoted the feature on a different thread.