You need to sign in to do that
Don't have an account?

Unable to find Apex action class referenced as 'AccountClass'.
there is no code errors but while importing source to org this error is coming.
Code is :
public with sharing class AccountClass{
@AuraEnabled(cacheable=true)
public static List<Account>getAccounts(){
try {
return[SELECT Name, Id FROM Account with SECURITY_ENFORCED];
}catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
}
}
Code is :
public with sharing class AccountClass{
@AuraEnabled(cacheable=true)
public static List<Account>getAccounts(){
try {
return[SELECT Name, Id FROM Account with SECURITY_ENFORCED];
}catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
}
}
This error can occur when the Apex class is not saved or compiled properly, or when there is a typo in the name of the Apex class being referenced.
Make sure that the Apex class is included in the package being deployed to the org.
Also, the Apex class has "with sharing" declared, which means that it enforces sharing rules on the records returned by the SOQL query. If the sharing settings are incorrect, it can cause issues with the deployment
Related:
https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000HDwCRSA1
https://salesforce.stackexchange.com/questions/352980/no-apex-action-available-for-class-method-error
If this information helps, please mark the answer as best. Thank you