You need to sign in to do that
Don't have an account?
di_zou
How do I display a Knowledge Article's "Most Viewed" on a custom VisualForce page?
I have a VisualForce Component that looks like this:
<ul> <apex:stylesheet value="{!URLFOR($Resource.custom_table_template)}"/> <table id="articles"> <th id="number">Article Number</th> <th id="title">Article Name</th> <th id="label">Article Type</th> <th id="date">Last Published Date</th> <knowledge:articleList articleVar="article" sortBy="mostViewed" pageSize="5"> <tr> <td>{!article.articlenumber}</td> <td><a target="_parent" href="{!URLFOR($Action.KnowledgeArticle.View, article.id)}">{!article.title}</a></td> <td>{!article.articletypelabel}</td> <td>{!article.lastpublisheddate}</td> </tr> </knowledge:articleList> </table> </ul>
How would I add a column that displays the "Most Viewed" of that article?
"Most viewed" is not an available column. If you want to get this information, you will have to run a SOQL query on KnowledgeArticle__ViewStat.
How would I do that in the VisualForce component?
So I did some googling, and I have some code now.
This is my Apex class:
global with sharing class Component_Query {
global String queryString {get; set;}
global List<sObject> results {get{
List<sObject> result = Database.Query(queryString);
return result;
} set; }
}
This is my Visualforce Component:
and this is my Visualforce Page
I put this page in a tab, but when I open the tab, nothing shows up.
Did you check if "article.id" is Knowledge Article Version Id or Knowledge Article Id? It can explain why the result is empty
KnowledgeArticleViewStat uses ParentId to reference KnowledgeArticle, so I changed:
to:
Based on this:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_guidelines_knowledge.htm
It seems "article.id" is the Knowledge Article Id.
Is my apex code for retrieving the value correct?
Have you solved this problem?
I am facing the same problem. I want to show the viewstat with every article by using this <knowledgeArticleList> component.
I am not getting how to do this so if you have done this then please help me
Thanks
Rishav kumar