2

We have a requirement to display the list of cases that are related to an article in a service console sidebar when viewing a case that has an article associated to it. In other words, I have a current case I am working with and I associated an article to the current case in context. It would be nice to see list of cases that are associated to the same article in context of current case in the left sidebar of the service console (case detail or case feed view). Support indicated that this is not an OOB feature. So I am trying to create a apex class and then create a VF page to display the list of cases on the left side bar of the console. While creating the apex I am getting the folloiwng error . Can some help provide feed back on what the isue might be?

[Error] Error: Compile Error: Illegal assignment from List to Case at line 16 column 5

Here is the code

public class CaseArticleExtension {

    public final Case thisCase;

    public String CaseId {get;set;}

    public String KnowledgeArticleId {get;set;}

    public Case selectedCase {get;set;}

    public CaseArticleExtension(ApexPages.StandardController stdController) {
        this.thisCase = (Case)stdController.getRecord();
        selectedCase = new Case();
    }
    public pagereference CaseArticle(){
    selectedCase = [SELECT CaseId FROM CaseArticle WHERE KnowledgeArticleId = :KnowledgeArticleId];
    return apexpages.currentpage();
}
}

VF Page:

<apex:page standardController="CaseArticle" extensions="CaseArticleExtension" >
    <apex:form >
        <span>Case Number:</span>
        <apex:inputText value="{!ArticleId}"/>
        <apex:commandButton value="Search" action="{!CaseArticle}"/>
    </apex:form>
</apex:page>
1

I see below issues with the code.

  1. The standardController you are using is of CaseArticle but stdController.getRecord(); you are typecasting to Case.

  2. selectedCase is an instance of Case Object. You are querying on CaseArticle object and assigning it to instance of Case Object which is technically wrong.

  3. You are trying to assign list of records to single instance. That's why you are getting the error.

  • Agreed. I need to rework this. My objective is to get the current id of the case , which is pretty easy and then get the article ids from the junction objects based on this case id and then get all the cases associated to those article id's and display those cases on the sidebar. Little involved. – rvpadman Jul 24 '15 at 22:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.