- Query or search generically across multiple types of articles.
- Filter on a specific version.
- Update standard fields in draft versions.
Knowledge__kav is derived from this object.
Supported Calls
describeLayout(), describeSObjects(), query(), retrieve(), search()
Special Access Rules
Knowledge must be enabled in your org. A user must have the View Articles permission enabled. Salesforce Knowledge users, unlike customer and partner users, must also be granted the Knowledge User feature license.
Fields
Usage
Use this object to query, retrieve, or search for articles across all types of articles depending on their version. You can update draft primary articles. Also, you can delete articles that aren’t drafts. Client applications can use KnowledgeArticleVersion with describeDataCategoryGroups() and describeDataCategoryGroupStructures() to return the category groups and the category structure associated with Salesforce Knowledge.
To access an article independent of its version, use the KnowledgeArticle object.
In Lightning Knowledge, the type of article is determined by the RecordType field on the concrete derived object (for example, Knowledge__kav). For Knowledge in Salesforce Classic, the type of article is determined by the ArticleType field and the concrete derived object uses the prefix of the article type name (for example, FAQ__kav for the FAQ article type).
SOQL Samples
SELECT Title, Summary FROM KnowledgeArticleVersion WHERE PublishStatus='Online' AND Language = 'en_US' WITH DATA CATEGORY Geography__c ABOVE_OR_BELOW europe__c AND Product__c BELOW All__c
SELECT Id, Title FROM Knowledge__kav WHERE PublishStatus='Draft' AND Language = 'en_US' AND RecordTypeId = '<specify RecordTypeId for Offer here>' WITH DATA CATEGORY Geography__c AT (france__c,usa__c) AND Product__c ABOVE dsl__c
SELECT Id, Title FROM Offer__kav WHERE PublishStatus='Draft' AND Language = 'en_US' WITH DATA CATEGORY Geography__c AT (france__c,usa__c) AND Product__c ABOVE dsl__c
SELECT Id FROM KnowledgeArticleVersion WHERE PublishStatus='Archived' AND IsLatestVersion=false AND KnowledgeArticleId='kA1D00000001PQ6KAM'
SOQL and SOSL with KnowledgeArticleVersion
- Filter on a single value of PublishStatus for best results. To find all versions of each article, omit the PublishStatus filter, but do filter on one or more master key IDs. To retrieve all archived versions for a given article, specify a SOQL filter where IsLatestVersion is false.
- In API version 46.0 and earlier, queries without a filter on PublishStatus return published articles by default. In API version 47.0 and later, draft, published, and archived articles are returned when Lightning Knowledge is enabled.
- To support security, only users with the “View Draft Articles” permission see articles whose PublishStatus value is Draft. Similarly, only users with the “View Archived Articles” permission see articles whose PublishStatus value is Archived
- Archived article versions are stored in the Knowledge__kav object. To query archived article versions, specify the article Id and set IsLatestVersion='0'.
- You can’t use binding variables in Apex SOQL statements with
KnowledgeArticleVersion objects. For example, the following SOQL statement
causes a compilation
error.
final String PUBLISH_STATUS_ONLINE = 'Online'; List<Knowledge__kav> articles = [ SELECT Id FROM Knowledge__kav WHERE PublishStatus = :PUBLISH_STATUS_ONLINE ];
Instead, use dynamic SOQL as follows. See Dynamic SOQL in Apex Developer Guide.
final String PUBLISH_STATUS_ONLINE = 'Online'; final String q = 'SELECT Id, PublishStatus FROM Knowledge__kav WHERE PublishStatus = :PUBLISH_STATUS_ONLINE'; List<Knowledge__kav> articles = Database.query(q);
Other Usage for SOQL and SOSL with KnowledgeArticleVersion
To expose the migrated_to_from_id on KnowledgeArticle and KnowledgeArticleVersion to the sObject API: expose MigratedToFromArticleVersion in KnowledgeArticleVersion.
- For SOQL:
- To filter by MigratedToFromArticleVersion, remove any other filters.
- When filtering by MigratedToFromArticleVersion, use the '=' or 'IN' operator.
- When filtering by MigratedToFromArticleVersion, the value can't be null or empty.
- SOSL doesn’t support MigratedToFromArticleVersion.
Associated Objects
This object has the following associated objects. Unless noted, they’re available in the same API version as this object.
- KnowledgeArticleVersionHistory
- History is available for tracked fields of the object.