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
JAYESH RATHORJAYESH RATHOR 

How Count Case records on a Knowledge Article

When Cases are attached to a knowledge article
  • How to get case count in trigger.
  • So based on case count I want to perform my bussiness logic
Please just any solution if you can suggest....urgent.

Thanks in advance.
AbhishekAbhishek (Salesforce Developers) 
Hi,

I believe this is the idea you're looking for: 

https://success.salesforce.com/ideaView?id=08730000000kyxQAAQ


Other Way:-

There is a class in Salesforce called KnowledgeArticleViewStat which can be used for accessing certain statistics related to the article views like the NormalizedScore and the ViewCount.

Viewcount gives the number of unique views an article has received on the selected channel.

A Channel is where the article is viewed:-
channels: for article views across all channels.
App: for the internal Salesforce Knowledge application.
Pkb: for article views in the public knowledge base.
Csp: for Customer Portal.
Prm: for article view in the partner portal.

For count, the number of article views by internal users. We can use the channel App since it meant for the internal Salesforce Knowledge application. You can do a SOQL query as following:

" SELECT id, ViewCount from KnowledgeArticleViewStat where Channel = 'App' "


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.


Thanks.
JAYESH RATHORJAYESH RATHOR
Hi Abhishek ,

No, My requiredment is like when any case attach to article, how to get case attach and  deattach count in trigger ,so based on case count on knowledge article. i want to peform my business logic ..please help.

Thanks in advance