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

License Management Custom Object

Hello,

I am trying to create a custom object within Salesforce called 'License Management'.  The purpose of this custom object is to track the historic values of the used/remaining licenses to see trends.  I was wondering how I can pull this information into the custom object.  Ideally I would like to create a process builder or trigger that runs monthly and creates a new 'License Management' record automatically with the values.  Anyone know how I can pull these numbers into a record?


User-added image
Thanks
Best Answer chosen by Ryan Mastbergen 4
VinayVinay (Salesforce Developers) 
Hi Ryan,

Yes, you can try creating an invocable method and use that in flow.

https://help.salesforce.com/articleView?id=flow_build_extend_apex.htm&type=5
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
Hi Ryan,

You can use below query to pull UserLicense.
 
SELECT Id,LastModifiedDate,LicenseDefinitionKey,MasterLabel,Name,Status,SystemModstamp,TotalLicenses,UsedLicenses,UsedLicensesLastUpdated FROM UserLicense

Kindly review below link which can give more details.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_userlicense.htm
https://salesforce.stackexchange.com/questions/140874/get-user-license-field-value

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
Ryan Mastbergen 4Ryan Mastbergen 4
Hey Vinay, What would be the easiest approach? Create an invocable apex class and use that in a flow? I don’t believe you can use queries straight in flows. Thanks
VinayVinay (Salesforce Developers) 
Hi Ryan,

Yes, you can try creating an invocable method and use that in flow.

https://help.salesforce.com/articleView?id=flow_build_extend_apex.htm&type=5
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm

Thanks,
This was selected as the best answer