0

I am using the knowledge(Knowledge__kav) object with 4-5 custom fields. For an article having 5 version. How can i query the archived article version with the custom field using KnowledgeArticleVersion object.

SELECT Id, Title, Revision_Notes__c, Short_description__c 
FROM Knowledge__kav 
WHERE Language= 'en_US' And PublishStatus='online' 
WITH DATA CATEGORY Knowledge_Base_Category__c BELOW Download__c.

In the above query Revision_Notes__c and Short_description__c are the custom fields. I needs to get those two fields value using KnowledgeArticleVersion object.

The below is the query which i was tried but getting error

SELECT 
Id, KnowledgeArticleId, VersionNumber, FirstPublishedDate, LastPublishedDate, ArchivedDate, KnowledgeArticleId.Revision_Notes__c, KnowledgeArticleId.Short_description__c   
FROM KnowledgeArticleVersion 
WHERE PublishStatus='Archived' AND IsLatestVersion=false AND KnowledgeArticleId='kA01s0000004fMaCAI'

Error :

LastPublishedDate, ArchivedDate,KnowledgeArticleId.Revision_Notes__c

^ ERROR at Row:1:Column:115 Didn't understand relationship 'KnowledgeArticleId' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

Can some one help me to know how to get the knowledge object custom fields using the KnowledgeArticleVersion object.

2 Answers 2

0

I guess you found since the question is old, but you just have to remove KnowledgeArticleId. in KnowledgeArticleId.Revision_Notes__c, KnowledgeArticleId.Short_description__c.

The fields are on the Knowledge article version (Knowledge__kav), not on the Knowledge article (Knowledge__ka). Knowledge articles don't have custom fields.

The data model for Knowledge is described here : https://developer.salesforce.com/docs/atlas.en-us.knowledge_dev.meta/knowledge_dev/knowledge_development_object_model.htm

In addition you can use the Salesforce Inspector browser plugin to easilly build and check your queries and to view all fields and relationships of all objects.

-2

In Setup->Digital Experiences->Settings enable the "Enable ExperienceBundle Metadata API" checkbox. Then your queries with custom fields will show the correct results. (Custom fields are stored on Knowledge__kav, not KnowledgeArticleVersion FYI)

(I believe this applies for imports/exports with DataLoader also)

1
  • How does enabling experiences to use ExperienceBundle help a query on a Knowledge object? Mar 25, 2022 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .