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
csorrowscsorrows 

Any way to show articles attached to case on custom VF page for portal user?

I have custom VF pages to display Case data for customer portal users, and I need to display the Articles (as in Salesforce Knowledge articles) attached to the case.  Articles can be displayed similar to a related list on standard page layouts, but I can't use those since all my pages are custom VF pages.

 

I thought I could use the "support:caseArticles" VF element, but it's displaying nothing for the customer portal user, no matter what options I use (and I am setting the caseId parameter).  I know the portal user has access to an attached article because he can see it in the "Articles" tab, and the article is enabled for access via the Customer Portal channel.

 

Is there something I'm missing?  Isn't this the purpose of the "support:caseArticles" element, to display attached articles to a case (and an optional search, but I don't care about the search part).  I did find the requirement to enable both Knowledge and Case Feed, which I did (the VF editor wouldn't even let me save the page until I'd enabled Case Feed).

 

Thanks

izayizay

You can add a related list to a visualoforce page using the <apex:relatedList list="ListName"/>

csorrowscsorrows

@izay

 

There are some objects that you can add as a Related List on a standard page layout, but they cannot be added to custom VF pages using the "apex:relatedList" element.  Three of them I know of are Case Comments, Notes/Attachments, and Articles.  All of these give errors when trying to use them in a VF "apex:relatedList" element.

 

I had to display (and allow users to add) Case Comments on my VF pages using custom queries and methods.

 

Because Articles are even more convoluted with how they're stored on the back end, I was hoping I could use the VF "support:caseArticles" element, but it's not working.

izayizay

In your visualforce page controller/extension you can query the KnowledgeArticleVersion object like so:

private List<KnowledgeArticleVersion> myArticles = new List<KnowledgeArticleVersion>();

//Constructor
public className(){
    //...Your code here
    myArticles = [SELECT Title, Summary, UrlName
    FROM KnowledgeArticleVersion 
    WHERE SourceId = :case.Id 
    AND IsLatestVersion = true AND PublishStatus='Online'];
    //... Your code here

}


//Return the articles list
public List<KnowledgeArticleVersion> getMyArticles(){
    return myArticles;
}

 Then display the articles in a <apex:PageBlockTable>

 

<apex:pageBlockTable value="{!myArticles}" var="a">
    <apex:column headerValue="Title">
        <apex:outputLink value="{!a.UrlName}" title="a.Title"/>
    </apex:column>
    <apex:column headerValue="Summary">
        <apex:outputField value="{!a.Summary}"/>
    </apex:column>
</apex:pageBlockTable>

 

csorrowscsorrows

@izay

 

Thanks so much!  I just started dumping all the contents of various Knowledge-related objects (using the Apex data loader) to see how things were tied together on the back end.  I also used a PageBlockTable to display case comments, so this gives me a good (and similar) starting point.

 

Thanks!