1

I have a Visualforce page in a Community that displays a users Case Details to them for their Case.

The page is using standardController="Case"

I am trying to get the list of attached knowledge articles from a Case w/o using <apex:relatedList list="CaseArticles"/>

The closest code I have come up with so far is:

public class CaseArticlesExtension {   
    public Id RecordId { get; set; }

    public CaseArticlesExtension(ApexPages.StandardController stdController) {
                RecordId = stdController.getId();
    }   

    public KnowledgeArticleVersion[] getArticles() {

            KnowledgeArticleVersion[] Articles = [SELECT Id, KnowledgeArticleId, UrlName, Title, Summary, LastPublishedDate, ArticleType 
            FROM KnowledgeArticleVersion 
            WHERE PublishStatus= 'Online' 
            AND Language = 'en_US'
            AND KnowledgeArticleId IN :[SELECT KnowledgeArticleId FROM CaseArticle WHERE CaseId = :RecordId]];

            return Articles; 
    }
}

This code has an error of "Invalid bind expression type of CaseArticle does not match domain of foreign key"

1 Answer 1

1

Try to reframe your select statement. First get the Ids and then get the versions for it.

  CaseArticle[] caseArticles = [SELECT KnowledgeArticleId FROM CaseArticle WHERE CaseId = :RecordId];

list<Id> kaIds = new List<Id>();
for (CaseArticle art: caseArticles) {
  kaIds.add(art.KnowledgeArticleId);
}

 KnowledgeArticleVersion[] Articles = [SELECT Id, KnowledgeArticleId, UrlName, Title, Summary, LastPublishedDate, ArticleType 
            FROM KnowledgeArticleVersion 
            WHERE PublishStatus= 'Online' 
            AND Language = 'en_US'
            AND KnowledgeArticleId IN :kaIds];
2
  • same error trying it this way: Invalid bind expression type of CaseArticle does not match domain of foreign key
    – Jason
    Apr 18, 2016 at 22:08
  • Now I see it. The Problem is that we were using the wrong type of Ids. Edited the code. Apr 18, 2016 at 22:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .