I would like to query the number of used Customer Community License in my org using the following query:
SELECT id,MasterLabel,Name,Status,TotalLicenses,UsedLicenses,UsedLicensesLastUpdated FROM UserLicense
However for some reason the result from DevConsole returns 0 (see attached userLicense-query-result.PNG) while it is shown clearly as a non-zero number in Company information (see attached company-info.PNG)
Does anyone know what might be the issue? This is also an issue when querying on workbench and other tools like Salesforce Inspector.
Besides, it doesn't look like a problem with other licenses.
4 answers
We are getting the result when we Query in Workbench, Salesforce Inspector, Query Editor in Developer Console and running the Query in Anonymous window. But when we run the Query inside a Schedulable class, it returns 0