Loading

Knowledge Article View Count Does Not Increase When Accessed in Sites

Julkaisupäivä: May 1, 2026
Kuvaus

Salesforce Sites have the capability of giving access to Knowledge in your Salesforce org. Users with Customer Community licenses can view the Knowledge articles through a site. Depending on which channel is used to display the article, the article view count increments accordingly.

When a Customer Community-related license user views an article on a site, the article view count is counted towards the customer channel. When an internal user views the article, the count increments against the Internal App channel.
See Articles Overview.

However, in scenarios where a controller class runs a SOQL (Structured Query Language) query to retrieve and display an article, the article view count is not automatically updated. This is because the standard view count increment requires the article to be accessed through the standard display mechanism. When custom code is used to retrieve the article via SOQL, the standard API call that updates the view count is not triggered.

Ratkaisu

To ensure that article view counts are tracked correctly when articles are retrieved via custom SOQL queries on Sites, add the UPDATE VIEWSTAT clause to your SOQL query. This instructs Salesforce to increment the view count for the article when the query executes, replicating the behavior of the standard channel display.

Your SOQL query should include the relevant article fields (such as id, KnowledgeArticleId, and Title), filter by PublishStatus='online', the appropriate Language, and the specific KnowledgeArticleVersion, and then append UPDATE VIEWSTAT at the end of the query.

A sample would look like this: 

SELECT id, KnowledgeArticleId, Title FROM FAQ__kav 
WHERE PublishStatus='online' and 
Language = 'en_US' and 
KnowledgeArticleVersion = 'kaxxxxxxxxxxxxx' 
UPDATE VIEWSTAT

For example, a query on a custom article type object (such as FAQ__kav) would retrieve the article record and simultaneously update its view count for the customer channel. Without this clause, the view count remains unchanged even when the article is displayed to the end user.

Knowledge-artikkelin numero

000386899

 
Ladataan
Salesforce Help | Article