You need to sign in to do that
Don't have an account?
Solution
Query and display Article ViewCount related to Article in Visualforce page
I have created one visualforce page which is showing complete list of Salesforce Knowledge Articles. Currently only Article Title field is shown on the page which I am quering from the standard object, KnowledgeArticleVersion.
I want to show one more field on the page which is TotalViewCount for a given article record. I am facing problem in impleting this fuctionality as the ViewCount field is there in another object called KnowledgeArticleViewSat.
Can someone help me? Thanks in advance
Thanks,
Pooja
Pooja,
The KnowledgeArticleVersion has a field, KnowledgeArticleId, which identifies the article independent of version. You should be able to use these Ids to query the KnowledgeArticleViewStat records that correspond to the articles.
The code below takes a list of KnowledgeArticleVersion records and returns a map from the KnowledgeArticleVersion ID to the view count for the article:
You can use this map to populate a list of wrapper class instances that contain all of the information from the KnowledgeArticleVersion records and the view count. Have your VF page repeat on this list of wrappers and you can display the view counts along with all the other information about the articles.
If you need help with the wrapper class, let me know. I'll be happy to help.
If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!
-Glyn
All Answers
Pooja,
The KnowledgeArticleVersion has a field, KnowledgeArticleId, which identifies the article independent of version. You should be able to use these Ids to query the KnowledgeArticleViewStat records that correspond to the articles.
The code below takes a list of KnowledgeArticleVersion records and returns a map from the KnowledgeArticleVersion ID to the view count for the article:
You can use this map to populate a list of wrapper class instances that contain all of the information from the KnowledgeArticleVersion records and the view count. Have your VF page repeat on this list of wrappers and you can display the view counts along with all the other information about the articles.
If you need help with the wrapper class, let me know. I'll be happy to help.
If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!
-Glyn
Thank you so much for your quick response. I have understood the concept of using the wrapper class. But I am new to wrapper class. Could you please help me with the code for wrapper class in this contextt?
It would be really helpful for me.
Thanks,
Pooja
I am able to display ArticleViewCount field on the visualforce page.
Thank you so much for the help.
Thanks,
Pooja