+ Start a Discussion
AddaAdda 

Knowledge Article to be shown on the Account?

Hi All,

I am skeptical if it is possible. Account has many cases. Is there any way if under a case a article is attached, can we show that article on account as a related list. For example Account A has Case 1,2 and 3 and if Case 1 has article as a,b and case 2 has article as x,y. Then account show related list of article as a,b,x and y. Is it possible as it doesn't seem there is a relationship between  account and article? Let me know 

Thanks
A
sandeep sankhlasandeep sankhla
Hi Adda,

Here you can create a inline visual force page where you can show all data as it comes in related list..

You can get all the cases based on current account Id, then you can get all the articles  from cases and then you can show all of them in a inline vf page on Account detail page..

Please try this and let me know if this solves your problem..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer 
AddaAdda
Thanks Sandeep for quick reply. 

I am not an expert in VF Page. Can you share some code for starters?

Thanks
Adda
sandeep sankhlasandeep sankhla
Hi Adda,

please refer the below code : 

public class Sample { 

    public Id Aid {get;set;}
    public list<article__c> lstArticles{get;set;}
    public set<Id> setCaseIDs = new set<Id>();
    
    public Sample(ApexPages.StandardController controller) {
        Account acc = new Account();
        Aid = controller.getId();
        lstArticles = new list<articles__C>();
        
        for(Case objCase : [Select Id from Case where AccountId = : Aid])
        {
            SetCaseIds.add(objCase.Id);
        }
        
        for(Article__c objArticle : [Select Id, Name from Article__c where CaseId IN SetCaseIds])
        {
            lstArticles.add(objArticle);
        }
    
    }     

    
    
}

VF Page

<apex:page standardController="Account" extension="Sample ">

    <table border="0" >

        <apex:repeat var="art" value="{!lstArticles}">

        <tr>

            <td>{!art.Name}</td>

                        
        </tr>

        </apex:repeat> 

    </table>

</apex:page>

You can query the data in your controller and then you can show them in Vf page as I shown above..

Please correct synatx erros and check with above code that will solve your issue..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer