Newer Version Available

This content describes an older version of this product. View Latest

Update an Article’s Viewstat with SOSL

Determine how many hits a Salesforce Knowledge article has had by using the UPDATE VIEWSTAT optional clause on a SOSL query. You can use the language attribute to search by locale.

The optional UPDATE VIEWSTAT clause is used to report on Salesforce Knowledge article searches and views. It allows developers to update an article’s view statistics. Also, the language attribute can be used to search by a specific language (locale). However, only one language can be specified in a single query. Make a separate query for each language that you want. Use the Java format, which uses the underscore (for example, fr_FR, jp_JP, and so on), to supply locales. Search the Web for “java locale codes” to get a list of supported locales.

You can use this syntax to increase the view count for every article you have access to online in US English:

1FIND {Title}
2RETURNING FAQ__kav (Title WHERE PublishStatus="Online" and
3language="en_US" and
4KnowledgeArticleVersion = 'ka230000000PCiy')
5UPDATE VIEWSTAT