Ticker

6/recent/ticker-posts

Header Ads Widget

Understand Salesforce Lightning Knowledge Data Model



While working with Lightning Knowledge, what I realized is that there is hardly any tutorial/post which explains the Knowledge Data Model in a very simple way. So I thought of writing my understanding with examples covering the part of the data model. I hope this will help you to understand the data model clearly and quickly.

Understanding the data model is always very important while doing the development as it will help you to play with the objects and do configure/customization that is possible, basically getting the maximum benefit of the platform.

To start with, the Knowledge Object Model is based on Abstract and Concrete objects. 


Core Abstract and Concrete Objects

The core abstract objects are - KnowledgeArticle and KnowledgeArticleVersion. The corresponding concrete versions are - Knowledge__ka and Knowledge__kav.
Below is the data model from the Salesforce Developer Guide -

Complete Data Model 



Relationship between Knowledge__ka and Knowledge__kav

As per the data model, the relationship between Knowledge__ka and Knowledge__kav is 1 to many. That is one Knowlegde__ka can have multiple Knowledge__kav. The link is happening through KnowledgeArticleId (remember KnowledgeArtcileId and Id are two different fields). So let's check the example below.

The "HelloWorld" article is having two versions - 

Now if I run the query against Knowledge__ka, I am getting one entry which provides me the KnowledgeArticleId

Now with the same KnowledgeArticleId, if I query Knowledge__kav, I will get one entry. Surprised?? Why only one entry where it should be two. The reason is that when you publish version 2, version 1 is marked as Archived. So SOQL query will not count the archived versions.


If I create another version and mark that as Draft (not publish), then the query will return two entries like below -

Note - Here is the link -

Knowledge__ka.Id = Knowledge__kav.KnowledgeArticleId

Relationship between Knowledge__kav and Knowledge__DataCategorySelection

Here is the same above document with two DataCategory - India and Canada


Note - Here is the link -

Knowledge__kav.Id = Knowledge__DataCategorySelection.ParentId

Relationship between Knowledge__ka and Knowledge__ViewStat

Knowledge__ViewStat is derived from abstract object KnowledgeArticleViewStat. It is used to store the number of views for a specific article.

The link is -

Knowledge__ka.Id = Knowledge__ViewStat.ParentId

Here is the query 


Relationship between Knowledge__ka and Vote

The object is used to store information about Upvote and Downvote against the article.

The link is -

Knowledge__ka.Id = Vote.ParentId

Here is the query 


I hope this will help you to understand the data model. Please let me know your feedbacks. Thanks.



Post a Comment

5 Comments

  1. Thanks for sharing Sudipta! Very helpful

    ReplyDelete
  2. Thanks for sharing Sudipta! Very helpful

    ReplyDelete
  3. This is really useful. The Knowledge data model is complex but you did a great job in explaining it.

    ReplyDelete