Category: Knowledge Management

How to use Knowledge Actions in Lightning Flow

Recently while implementing Knowledge for one of my customers, I spend quite a good amount of time doing operations on Knowledge Articles through Flow. This post will focus on two highly used Knowledge Article operations i.e. Publish and Edit.Before I go into further details, I will highly recommend you go through the below post to understand the Knowledge Data Model. Understanding Knowledge Data Model is the key as it will help you to use these actions in flow effectively and correctly. Here is the post -Understanding Salesforce Lightning Knowledge Data ModelWith the assumption that you know Data Model quite well, let’s dive in -Edit Knowledge ArticleFrom Salesforce Flow, you can now edit the Knowledge article as a draft. To do that, you need to use the action and then “Create draft from online knowledge article” Knowledge article action as shown belowHere are the parameters -Action – The possible values are “EDIT_AS_DRAFT_ARTICLE” and “EDIT_AS_DRAFT_TRANSLATION”.Unpublish – “True” will archive the current published version and create a draft version. “False” will keep the current version published and create a new draft version.Article ID: Article Id of the master published article. A draft article will be created from this one.Publish Knowledge ArticleSimilar to the above from Salesforce Flow, you can now publish the Knowledge article. To do that, you need to use the action and then “Publish Knowledge Articles” Knowledge article action as shown belowHere...

Read More

Using Apex with Knowledge

 In continuation of my effort to make Lightning Knowledge easily understandable for all, today I am going to show how Salesforce Knowledge can be accessed using Apex. Salesforce Knowledge can have Apex Triggers and be accessible through Apex code. Actually, Salesforce provides some standard apex classes related to Knowledge Management that can be called for actions like publishing, editing as draft, archiving, and more.Before I start, I would recommend you going through my earlier posts -Understanding Salesforce Lightning Knowledge Data ModelHandy SOQL/SOSL Queries for KnowledgeWe can use the methods in KbManagement.PublishingService class to manage the lifecycle of an article. I am going to explain some of the few classes which developer needs mostly, but to know about all the methods, I highly recommend you going through the documentation here.Editing an Article as DraftWe can use the below method to edit an article as draft – String newId = KbManagement.PublishingService.editOnlineArticle(                    knowledgeArticleId,                     false               );Where the 1st input parameter is the KnowledgeArticleId (Note – This is not the Knowledge Record Id).2nd parameter is a Boolean value where false will not unpublish the already published articles and true will unpublish the already published article.This method will return the new draft master version ID of the article.Note – We need to keep this in mind that this method is not bulkified. So if...

Read More

Handy SOQL/SOSL Queries for Knowledge

 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

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 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

Compare Knowledge Articles – WoW Feature

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
Loading