Newer Version Available
KnowledgeArticleVersion
- 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
1SELECT Title, Summary
2FROM KnowledgeArticleVersion
3WHERE PublishStatus='Online'
4AND Language = 'en_US'
5WITH DATA CATEGORY Geography__c ABOVE_OR_BELOW europe__c AND Product__c BELOW All__c1SELECT Id, Title
2FROM Knowledge__kav
3WHERE PublishStatus='Draft'
4AND Language = 'en_US'
5AND RecordTypeId = '<specify RecordTypeId for Offer here>'
6WITH DATA CATEGORY Geography__c AT (france__c,usa__c) AND Product__c ABOVE dsl__c1SELECT Id, Title
2FROM Offer__kav
3WHERE PublishStatus='Draft'
4AND Language = 'en_US'
5WITH DATA CATEGORY Geography__c AT (france__c,usa__c) AND Product__c ABOVE dsl__c1SELECT Id
2FROM KnowledgeArticleVersion
3WHERE PublishStatus='Archived'
4AND IsLatestVersion=false
5AND 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.
1final String PUBLISH_STATUS_ONLINE = 'Online'; 2List<Knowledge__kav> articles = [ 3SELECT Id FROM Knowledge__kav 4WHERE PublishStatus = :PUBLISH_STATUS_ONLINE 5];Instead, use dynamic SOQL as follows. See Dynamic SOQL in Apex Developer Guide.
1final String PUBLISH_STATUS_ONLINE = 'Online'; 2final String q = 'SELECT Id, PublishStatus FROM Knowledge__kav 3WHERE PublishStatus = :PUBLISH_STATUS_ONLINE'; 4List<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.