Salesforce Error no profiling in Apex, give profile access to that class
•18 min read

Here's a clear explanation of the error “no profiling in Apex, give profile access to that class” and how to fix it with proper code + steps.
✅ Why This Error Happens
This error usually appears when:
1. A profile does NOT have access to the Apex class you're trying to run
- The class is not visible to that profile.
- The Apex class is not added under Profile → Apex Class Access.
2. Running code from Triggers, LWC, Aura, Flow, or API
If the user executing the class doesn’t have Apex class access, Salesforce blocks the execution.
✅ How to Fix It (UI Method)
Step 1: Go to Setup
- Setup → Profiles
- Select the profile (e.g., Custom Standard User)
Step 2: Enable Apex Class Access
- Scroll to Apex Class Access
- Click Edit
- Move your Apex class from Available → Enabled
- Save
✅ Fix Using Permission Set (Recommended Method)
Instead of modifying profiles, create a Permission Set and grant Apex Class Access.
Steps
- Setup → Permission Sets
- New Permission Set
- Go to Apex Class Access
- Add your class → Save
- Assign this Permission Set to the user
✅ Fix Using Apex Code (Metadata Deploy)
You cannot directly change profile permissions inside Apex,
but you can check profile access programmatically.
Below is a safe Apex utility to check whether a profile has access:
public class CheckApexClassAccess {
public static Boolean hasClassAccess(String className) {
try {
ApexClass ac = [SELECT Id, Name FROM ApexClass WHERE Name = :className LIMIT 1];
SetupEntityAccess sea = [
SELECT Id
FROM SetupEntityAccess
WHERE SetupEntityId = :ac.Id
AND Parent.Profile.Name = :UserInfo.getProfileId().getDescribe().getName()
LIMIT 1
];
return sea != null;
} catch (Exception e) {
return false;
}
}
}
JavaScriptUsage
Boolean allowed = CheckApexClassAccess.hasClassAccess('MyClass');
if (!allowed) {
throw new AuraHandledException('No profile access to this Apex class.');
}
JavaScript✅ Example: Apex Class Secured with Profile Check
public with sharing class MySecureClass {
@AuraEnabled
public static String getData() {
if (!CheckApexClassAccess.hasClassAccess('MySecureClass')) {
throw new AuraHandledException('Profile does not have access to MySecureClass.');
}
return 'You have access!';
}
}
JavaScript✅ Shortcut Permission Check (Simpler Code)
if (!FeatureManagement.checkPermission('Your_PermSet_Permission')) {
throw new UnauthorizedException('Access denied.');
}
JavaScriptUse this when you add a custom permission to a permission set.
✅ Final Summary
| Issue | Fix |
|---|---|
| Error: no profiling in Apex | User profile does not have class access |
| Best Solution | Add Apex class to Permission Set |
| Alternative | Add Apex Class Access in Profile |
| Optional | Add code to check/stop execution if profile lacks access |
Tags:
Related Posts

How to Automatically create a follow-up Task when a Lead is converted

How You need to update a related child record whenever a parent record’s status changes, but only if the status is “Closed Won.” How would you design this in Apex?
