SOQL Query – How to Select Knowledge Object

I'm trying to get all articles which are published and online.
In my user I turned on all permission set and so one to have access to Knowledge.

List<Knowledge__kav> myList= [SELECT Id, KnowledgeArticleId, PublishStatus, Language, Title, Summary, ArticleNumber, ArticleType, ArticleBody__c FROM Knowledge__kav WHERE PublishStatus='Online'];

Above is my query, but in log i got sth like this.

sObject type 'Knowledge__kav' is not supported.

Can somebody know how to get all object of this type in Apex class ?

Best Answer

Knowledge can be a bit confusing to query. I don't believe querying knowledge directly is supported. However, you can query the knowledge articles per article type. For instance, if your article type is called Offer, you can query it like:

SELECT Title
FROM Offer__kav
WHERE PublishStatus='online'
Related Topic