Happy Monday!! In my last post, I have explained the Data Model around Salesforce Lightning Knowledge. If you haven’t gone through that post, I highly recommend you going through the post “Understanding Salesforce Lightning Knowledge Data Model” as it is going to help you to understand the queries in this post.Let’s first create the article – “Hello World” and below are the different versions with different publishing status. Below article properties which I will be using the query -Article Number: 000001000Knowledge Article Id: kA03t00000063w2CAAFetching Latest Knowledge Article VersionSELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = ‘kA03t00000063w2CAA’ AND IsLatestVersion = TrueFetching Published Knowledge Article VersionSELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = ‘kA03t00000063w2CAA’ AND PublishStatus = ‘Online’Fetching Draft Knowledge Article VersionSELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = ‘kA03t00000063w2CAA’ AND PublishStatus = ‘Draft’Fetching Archived Knowledge Article VersionsSELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = ‘kA03t00000063w2CAA’ AND PublishStatus = ‘archived’ AND IsLatestVersion = FalseThis one is tricky, as to query Archived article versions, KnowledgeArticleId and IsLatestVersion = False and PublishStatus = archived should be mentioned.Note -Using bind variables with Apex SOQL Statements with KnowledgeArticleVersion is not allowed. So you need to use dynamic SOQL like below -final String ONLINE_ARTICLE = ‘Online’;final String myQuery = ‘SELECT Id FROM Knowledge__kav WHERE PublishStatus = :ONLINE_ARTICLE’;List<Knowledge__kav> allArtciles = Database.query(myQuery);Working with DATA CATEGORYWITH DATA CATEGORY is an optional clause in SOQL and it helps to identify articles linked with one or more...Read More
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 ObjectsThe 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__kavAs 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 KnowledgeArticleIdNow with the same KnowledgeArticleId, if I query Knowledge__kav, I will get one entry. Surprised?? Why only one entry where it should be...Read More
In Spring’20, Salesforce introduced one feature which was pending for a long time and also got a good amount of vote in Idea Exchange.Recently while working with a customer who is trying to implement Lightning Knowledge, it was one of the top priority requirement. And I don’t want to do any custom development for this. But to my surprise, I saw that Salesforce already introduced this feature in Spring’20 as Beta.I was like …So thought of sharing this information here how we can use this great feature.Basically in the article layout all we need to do is include the Lightning component “Article Version Comparison” and then we can select the versions we want to compare. Screenshots are given below.This is very useful feature for the Approver to see the actual changes before taking any decisions. Also for the viewer also, they can see the changes between different versions(provided they have the permission to view versions of the...Read More
- Salesforce API – New and Changed Objects
- New Video – Mastering Google Cloud Storage Part 3 – Diving Deep into Retention Policies!
- Salesforce Winter 24 Release | Sharing Related Enhancements
- How To Perform Enhanced List Sorting with Comparator Interface
- Unleashing The Power of AI: Salesforce and Tableau GPT