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: 000001000
- Knowledge Article Id: kA03t00000063w2CAA
Fetching Latest Knowledge Article Version
SELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = 'kA03t00000063w2CAA' AND IsLatestVersion = True
Fetching Published Knowledge Article Version
SELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = 'kA03t00000063w2CAA' AND PublishStatus = 'Online'
Fetching Draft Knowledge Article Version
SELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = 'kA03t00000063w2CAA' AND PublishStatus = 'Draft'
Fetching Archived Knowledge Article Versions
SELECT Id,PublishStatus,Title FROM Knowledge__kav WHERE KnowledgeArticleId = 'kA03t00000063w2CAA' AND PublishStatus = 'archived' AND IsLatestVersion = False
Working with DATA CATEGORY
- ObjectTypeName = KnowledgeArticleVersion to query all articles types.
- ObjectTypeName = an article type API Name to query a specific article type.
- ObjectTypeName = Question to query questions.
- PublishStatus
- “online” to published articles.
- “archived” to query archived articles
- “draft” to query draft articles
- Id = articles Id.
SELECT Title FROM KnowledgeArticleVersion WHERE PublishStatus='online' WITH DATA CATEGORY NorthAmerica__c ABOVE canada__c
DATA CATEGORY Filtering Selectors
Earth__c
Asia__c
India__c
Bangladesh__c
NorthAmerica__c
Canada__c
USA__c
Europe__c
Switzerland__c
France__c
German__c
SELECT Title FROM KnowledgeArticleVersion WHERE PublishStatus='online' WITH DATA CATEGORY Earth__c AT Canada__c
SELECT Title FROM KnowledgeArticleVersion WHERE PublishStatus='online' WITH DATA CATEGORY Earth__c ABOVE German__c
SELECT Title FROM KnowledgeArticleVersion WHERE PublishStatus='online' WITH DATA CATEGORY Earth__c BELOW Asia__c
SELECT Title FROM KnowledgeArticleVersion WHERE PublishStatus='online' WITH DATA CATEGORY Earth__c ABOVE_OR_BELOW Europe__c