Print this page

Update "Last Viewed Date" on KnowledgeArticle

Knowledge Article Number 000206591
Description LastViewedDate is not available on KnowledgeArticleVersion, but it appears to be available on KnowledgeArticle as per below link:
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_knowledgearticle.htm 
However, both LastViewedDate and LastReferencedDate are always returned as null.

For example we can execute below queries to verify the results:

 
select Id,LastViewedDate,LastReferencedDate from KnowledgeArticle where Id = 'kA0i0000000CWZO'
 
select Id,LastViewedDate,LastReferencedDate from KnowledgeArticle where Id = 'kA0i0000000CWZO' update viewstat



 
Resolution Using "from KnowledgeArticle" in SOQL query will give "Null" value. To get the correct results we should use the API names instead of using Object name. For example "Article Type Dev Name", which is yourArticleTypeName__ka.

In this case: 
select Id,LastViewedDate,LastReferencedDate from TEST_123__Type1__ka where Id = 'kA0i0000000CWZO'

This query: 
select Id,LastViewedDate,LastReferencedDate from TEST_123__Type1__ka where Id = 'kA0i0000000CWZO' update viewstat
will fire an event to update the record.

To double verify, you can executed followed query to check the view count: 
SELECT Id, ViewCount, parent.id FROM KnowledgeArticleViewStat where parent.id = 'yourArticleID'

 




promote demote