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
Michelle SotoMichelle Soto 

ERROR: You don't have access to the Apex class named

Hi,

We have a problem with the community public version. 

When a user public try to view the knoledge base, appear the next error: "ERROR: You don't have access to the Apex class named 'DataCategoryController'."

I find information about that but is referent to profiles acces to Apex Class. The error appear to public user so i can´t give acces to Apex Class if are public user without licences.

The Apex Class is a controller for a aura component. When i see the component with my salesforce user no appeat the error.

Code:
public class DataCategoryController {
    @AuraEnabled
    public static Wrapper getDataCategories(){
        
        Wrapper wrap = new wrapper();
        wrap.items = new List<Node>();
        wrap.label = 'Ayuda y soporte tecnico';
        
        Map<String, Knowledge__DataCategorySelection> mapKDCS = new Map<String, Knowledge__DataCategorySelection >();
        List<Knowledge__DataCategorySelection> lstkdcs =  [SELECT DataCategoryGroupName,DataCategoryName,Id FROM Knowledge__DataCategorySelection];
        
        for(Knowledge__DataCategorySelection KDCS :lstkdcs ){
            mapKDCS.put( KDCS.DataCategoryName, KDCS );
        }
        
        for(Knowledge__DataCategorySelection KDCS :mapKDCS.values() ){
            Node DCNode = new  Node();
            DCNode.label = KDCS.DataCategoryName;
            DCNode.name = KDCS.DataCategoryName;
            DCNode.expanded = true;
            wrap.items.add( DCNode );
        }
        
        system.debug('wrap: '+ wrap);
        return wrap;
    }
    
    @AuraEnabled
    public static List<Knowledge__kav>  getArticleVersion(String topicName){
        
        Set<Id> setTopicEntyId = new Set<Id>();
        
        List<TopicAssignment> lstTA = [SELECT EntityId FROM TopicAssignment WHERE Topic.Name = :topicName LIMIT 900 ];
        system.debug('lstTA: '+lstTA);
        
        for(TopicAssignment ta :lstTA){
            setTopicEntyId.add(ta.EntityId);
        }
        
        system.debug('setTopicEntyId: '+setTopicEntyId);
        
        List<Knowledge__kav > lstKAV = [
            SELECT Id, Title, FirstPublishedDate, LastPublishedDate,UrlName 
            FROM Knowledge__kav
            WHERE PublishStatus = 'Online' AND Id in  :setTopicEntyId];
        system.debug('lstKAV: '+lstKAV);
        return lstKAV;
    }
    
        
    public class Wrapper{
        @AuraEnabled
        public String label{get;set;}
        @AuraEnabled
        public List<Node> items{get;set;}
    }
    
    public class Node{
        @AuraEnabled
        public String label{get;set;}
        @AuraEnabled
        public String name{get;set;}
        @AuraEnabled
        public Boolean expanded{get;set;}
        @AuraEnabled
        public List<node> items{get;set;}
    }
}

Do you know the solution for this error?
Do you know another method to solve the error?

Thanks!
 
AnkaiahAnkaiah (Salesforce Developers) 
Hi Michelle,

Refer the below help article for different issues for aricle visibility.

https://help.salesforce.com/s/articleView?id=000338590&type=1

Refer the below app exchange product will help you to access the article by public users.
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000059QxXEAU&tab=r&revId=a0S3000000H8VOgEAN

If the above information helps, Please mark it as best answer for future reference.

Thanks!!