Thanks. I am trying to fetch UsedLicenses / TotalLicenses from UserLicense object and I am using API 32.0 but when I try to access those fields, error says "No such column 'TotalLicenses' on entity 'UserLicense'.I checked with Salesforce Support and as per them these fields are enabled for our orgainsation. But then When I have tried to understand object details with ObjectDescribe using Workbench, I am not able to find these fields. Is anyone here able to get these field details. if so how? 3. How can we ensure these fields are enabled for us? Pls help.
2 Answers
These fields are available only through API call. You have to make Webservice SOAP Call to retrieve them.
Also you can vote for this idea to make these fields Generally Available AND available through Apex Code, SOQL, Developer Console and Workbench.
Also you might be interested in this idea.
==== Update ====
I created a managed beta package which may serve as workaround for this. It screenscrapes company profile page and gets number of total license.
This package includes a User_License_Extended__c custom object which contains Total License number and Used Licenses number ( and some more fields ), these numbers are updated whenever a user is activated or deactivated or user profile is changed assuming package is properly set up with necessary data
Install link for production-like org https://login.salesforce.com/packaging/installPackage.apexp?p0=04t580000001ENa
More details and release notes https://patlatus.wordpress.com/2016/03/07/salesforce-uletas-beta-1-0-release-notes/
I would've prefered to leave a comment, but because my reputation is not high enough I couldn't. This is my first answer post. I have a workaround that should help you get the results you need since you have not been successful in accessing that TotalLicense field. You could query the UserLicense object in Workbench and export it to Excel with the Bulk CSV option in Workbench.
SELECT Id, LicenseDefinitionKey, MonthlyLoginsEntitlement, MonthlyLoginsUsed, Name, SystemModstamp FROM UserLicense
Then you could query the Profile Object and export to Excel using the Bulk CSV option.
SELECT Description, Id, IsSsoEnabled, LastModifiedDate, Name, UserLicenseId, UserType FROM Profile
Use VLookup in Excel to match the UserLicenseId column on the Profile table with the ID column on the UserLicense table to return the Name column value from the UserLicense table to the Profile table. Name that column License Name on the Profile table.
Go back to Workbench and query the User object and export it to Excel using the Bulk CSV option.
SELECT Id, IsActive, Name, ProfileId, UserType FROM User WHERE IsActive=True
Use VLookup to match the ProfileId column on the User table with the Id column on the Profile table to return the License Name to the User table. then you could use count functions and sorting to get the total number of each license. Hopefully that makes sense. If you need VLookup instructions I could provide those as well if you need help. Hopefully this is helpful.
-
1This gives you the licenses used, which you can also get from: SELECT COUNT(ID), Profile.UserLicense.Name, Profile.UserType FROM User WHERE IsActive = true GROUP BY Profile.UserLicense.Name, Profile.UserType– user735Apr 9, 2015 at 22:31
-
Would love to know how to get get the total available licenses - haven't figured that one out yet ...– user735Apr 9, 2015 at 22:32
TotalLicense
column? FYI the documentation gives the column name asTotalLicenses
notTotalLicense
(or totollicense as you mentioned in your question)