aidonsnous
aidonsnous

Reputation: 1503

How can I know the list of user running Apex code in our org with their respective licence type?

I have been looking for ways to list/access the list of users with with their respective type licenses(Partner or Admin or Community) running/executing apex on our org but have not found anything explaining how I can do that.

Any help to help understand how I can achieve this will be greatly appreciated.

Upvotes: 0

Views: 693

Answers (1)

eyescream
eyescream

Reputation: 19637

Unclear.

There's some tracking "user X used visualforce page/apex class Y" but Event Monitoring is a paid addon, bought separately or as part of Shield (better field history tracking and encryption). You should be able to experiment with it in your Developer Edition / Trailhead Playground before deciding to buy.


Without that... you'll have to marry few queries together but the results will be so-so.

SELECT Name, UserType, Profile.UserLicense.MasterLabel, Profile.UserLicense.LicenseDefinitionKey
FROM User
WHERE IsActive = true

for license types. This is about "main" user license. Your user can have "feature licenses" (Salesforce Content User, Marketing User, Knowledge User...) that are just checkboxes on user record. And can have permission sets assigned with some managed package licenses for example.

For async jobs (scheduled, queueable, batch, @future...) you should be able to query the AsyncApexJob (keeps logs for 1 week I think) or CronTrigger + CronJobDetail to see scheduled jobs. That'll include dashboard & report runs too though, filter them out using that cronjobdetail

Last but not least you can query who has access (via profile or permission sets) to run class X - but that doesn't mean they actually run it. For that you'd need to query. Some sample queries for that are in SetupEntityAccess documentation.

Upvotes: 1

Related Questions