0

Using this within digital experience. Works when logged in, but not for non-signed in users.

The APEX function:

@AuraEnabled(cacheable=true)
public static List<Knowledge__kav> searchByTopic(string tSearchString, string articleType) {
    return [
        SELECT Title, Id, UrlName, Summary, LastModifiedDate
        FROM Knowledge__kav 
        WHERE Article_Type__c = :articleType 
        AND Id IN (
            SELECT EntityId FROM TopicAssignment WHERE TopicId = :tSearchString
        )
        LIMIT 1000
    ];
}

The Error Message on Call:

message: "Implementation restriction: TopicAssignment only allows security evaluation for non-admin users when either (1) LIMIT is specified and at most 1000 or (2) WHERE is specified and filter on Id or Entity"

This is being called within a LWC that takes the {!topicId} and then pulls the articles based on that.

I thought that adding the Limit in this way would fix it but its still sending me this error. Open to other ways to format this query.

EDIT: Changed the method to the following and it worked. Is this best practice or is there a better way?

@AuraEnabled(cacheable=true)
public static List<Knowledge__kav> searchByTopic(string tSearchString, string articleType) {


    TopicAssignment[] assignmentList = [SELECT EntityId FROM TopicAssignment WHERE TopicId = :tSearchString LIMIT 1000];
    List<Id> assignmentListIds = new List<Id>();
        for (TopicAssignment ta : assignmentList) assignmentListIds.add(ta.EntityId);

    return [
        SELECT Title, Id, UrlName, Summary, LastModifiedDate
        FROM Knowledge__kav 
        WHERE Article_Type__c = :articleType 
        AND Id IN :assignmentListIds
        LIMIT 1000
    ];
} 

0

Your Answer

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

Browse other questions tagged or ask your own question.