0

I am trying to create a VF page to pull all knowledge articles with few custom fields. We have 10 article types in our org. As per salesforce documentation I need to query on each article type object to get knowledge articles of that particular article type as :

SELECT Id, KnowledgeArticleId, Title, PublishStatus, Isdeleted 
                             FROM Help_Center__kav WHERE 
                             language = 'en_US' 
                             AND publishStatus = 'Online'

So if I have 10 article types (or more) do we need to make 10 SOQL Queries? If one more article type is added, I will have to change my apex logic.

  1. Could anyone suggest a better approach?

  2. Is there a way I can query related fields of article types when querying Knowledge article version object?

1 Answer 1

1

You can use KnowledgeArticleVersion object to query for articles across all article types depending on their version.

Try this

SELECT Title, Summary FROM KnowledgeArticleVersion WHERE PublishStatus='Online' AND Language = 'en_US'

Refer KnowledgeArticleVersion object in Salesforce

1
  • 1
    I need custom fields from Help_Center__kav (ArticleType__kav object) and looks like there is no direct relationship between KnowledgeArticleVersion and ArticleType So querying on KnowledgeArticleVersion won't help
    – C0DEPirate
    Commented Jul 25, 2017 at 13:12

You must log in to answer this question.

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