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 –
In the realm of Salesforce, understanding the intricacies of its data model is crucial for effective customization and utilization of the platform’s functionalities. Among the nuances lies the concept of polymorphic fields, particularly evident in the Event and Task objects through the whoid and whatid fields. These fields play a pivotal role in associating records with various objects, enabling flexibility and efficiency in managing sales and customer interactions. In this blog post, I will delve into the disparities between whoid and whatid, shed light on their polymorphic nature, and provide examples of SOQL queries to leverage their capabilities.
Special thanks to our speaker, Alba Rivas, for the session on “Shadow DOM, CSS and Styling Hooks in LWC“. Presentation: Shadow DOM, CSS and Styling Hooks in LWC what you need to know from Sudipta Deb ☁ Recording: Reference Links: SLDS Design Tokens Github...
If you love how the record page is displayed in Classic, then what I am going to share in this post, you will definitely like that. If you like videos, then I have created a small video as well to explain the steps. You can check the video here. In Classic,...
Need your suggestion on to update publish articles of 37k volume to Draft , and then need to do update of a custom field from Data Loader and then again update those to Publish status.With Dataloader, I can do the 2 and 3 steps. But the first step to change to draft, I am not aware of this. Any method of Batch Apex with similar example code exists, Please share.
Thanks for sharing Sudipta! Very helpful
Thanks for sharing Sudipta! Very helpful
Thank you Denver for your comment
This is really useful. The Knowledge data model is complex but you did a great job in explaining it.
Thank you Yusuf for your comment.
Hi Sudipta
Need your suggestion on to update publish articles of 37k volume to Draft , and then need to do update of a custom field from Data Loader and then again update those to Publish status.With Dataloader, I can do the 2 and 3 steps. But the first step to change to draft, I am not aware of this. Any method of Batch Apex with similar example code exists, Please share.
Thanks in Advance!
Nalini
srinalini.ch@gmail.com
Hi, I want to create report on “Knowledge Article views” that should be grouped by “Knowledge Data category”. Please help me on this
Can you please try joining the article views with categories?