I am having an SOQL query just to check that which user is having what all permissions to an apex class. So the SOQL looks like this

SELECT RecordId, HasReadAccess, HasAllAccess,HasDeleteAccess,HasEditAccess, HasTransferAccess, MaxAccessLevel
 FROM UserRecordAccess where UserId='0052v00000cDteP' and recordId='01p2v00000HaUmj' 

here recordId is Id of ApexClass and userId is the id of the user which is assigned to custom System admin profile with author apex permission unchecked.

As per my understanding it should show me no edit access on the class, but it shows following result

enter image description here

why the result shows hasEditAccess as true when the user does not have author apex permission itself, also the user doesn't have any extra permission set assigned


I suspect that your custom profile does not actually remove access to modify Apex code. If run against a Standard Platform User, this query returns the expected values (HasReadAccess true, HasEditAccess et al. false) in my org.

Since authoring Apex isn't permissioned on a per-class basis, the permission fields on UserRecordAccess aren't meaningful for Apex classes in quite the same way they are for sObjects. Classes don't have record-level sharing at all, for example. If you just want to find out whether a user has Author Apex permission, query for that permission specifically. It's called PermissionsAuthorApex. Here's an example by Adrian Larson of how to perform that kind of query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.