WITH DATA CATEGORY
[WITH [DATA CATEGORY] filteringExpression]
If WITH DATA CATEGORY is specified, the query() returns only matching records that are associated with the specified data categories and are visible to the user. If unspecified, the query() only returns the matching records that are visible to the user.
- KnowledgeArticleVersion to query all article types
- an article type API Name to query a specific article type
- Question to query questions
-
PublishStatus to query articles depending on their status in the publishing cycle:
- WHERE PublishStatus='online' for published articles
- WHERE PublishStatus='archived' for archived articles
- WHERE PublishStatus='draft' for draft articles
- Id to query an article based on its id
For information on article types or questions, see “Knowledge Article Types” in Salesforce Help.
filteringExpression
The filteringExpression in the WITH DATA CATEGORY clause uses the following syntax:
dataCategorySelection [AND [dataCategorySelection][...]
The examples in this section are based on the following data category group:
Geography__c
ww__c
northAmerica__c
usa__c
canada__c
mexico__c
europe__c
france__c
uk__c
asia__c
The category filtering in the statements below is highlighted in bold.
- SELECT Title FROM KnowledgeArticleVersion WHERE PublishStatus='online' WITH DATA CATEGORY Geography__c ABOVE usa__c
- SELECT Title FROM Question WHERE LastReplyDate > 2005-10-08T01:02:03Z WITH DATA CATEGORY Geography__c AT (usa__c, uk__c)
- SELECT UrlName FROM KnowledgeArticleVersion WHERE PublishStatus='draft' WITH DATA CATEGORY Geography__c AT usa__c AND Product__c ABOVE_OR_BELOW mobile_phones__c
You can only use the AND logical operator. The following syntax is incorrect as OR is not supported:
WITH DATA CATEGORY Geography__c ABOVE usa__c OR Product__c AT mobile_phones__c