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
Ryan Mastbergen 5Ryan Mastbergen 5 

Creating a License Snapshot

I am working on creating a new custom object called 'License Managment' that would automatically create a new record the first of every month. This way we have a 'snapshot' or history of our usuage.  I know you can pull these figures in a report, however is there a way to pull them into a field? 

The numbers I want to pull into a field are...
- Available Licenses
- Used Licenses
Gaurav Sharma 472Gaurav Sharma 472
you need to create a batch class to insert new records into your custom object every month.


you can use below query to get available and used license for each license type.



SELECT MasterLabel,Name,Status,TotalLicenses,UsedLicenses,UsedLicensesLastUpdated FROM UserLicense


refer to below url for more details about the query
https://salesforcecodex.com/2019/08/getting-salesforce-licenses-information/