Skip to content

QRY_Builder.DataCategoryBuilder

Class

apex
global inherited sharing class QRY_Builder.DataCategoryBuilder

Fluent builder for WITH DATA CATEGORY filters.

Example

apex
List<SObject> articles = QRY_Builder.selectFrom(KnowledgeArticleVersion.SObjectType)
    .fields(new List<String>{'Id', 'Title'})
    .condition('PublishStatus').equals('Online')
    .withDataCategory('Geography__c').at('USA__c')
    .withDataCategory('Product__c').below('Electronics__c')
    .toList();

Methods

MethodDescription
global QRY_Builder.Builder above(List<String> categoryNames)Filters to categories above any of the specified categories in the hierarchy.
global QRY_Builder.Builder above(String categoryName)Filters to categories above the specified category in the hierarchy.
global QRY_Builder.Builder aboveOrBelow(List<String> categoryNames)Filters to categories above or below any of the specified categories in the hierarchy.
global QRY_Builder.Builder aboveOrBelow(String categoryName)Filters to categories above or below the specified category in the hierarchy.
global QRY_Builder.Builder at(List<String> categoryNames)Filters to any of the specified categories.
global QRY_Builder.Builder at(String categoryName)Filters to the exact specified category.
global QRY_Builder.Builder below(List<String> categoryNames)Filters to categories below any of the specified categories in the hierarchy.
global QRY_Builder.Builder below(String categoryName)Filters to categories below the specified category in the hierarchy.

above

apex
global QRY_Builder.Builder above(List<String> categoryNames)

Filters to categories above any of the specified categories in the hierarchy.

Parameters

ParameterTypeDescription
categoryNamesListThe category API names

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryNames is null or empty

Example

apex
.withDataCategory('Geography__c').above(new List<String>{'USA__c', 'Canada__c'})
apex
global QRY_Builder.Builder above(String categoryName)

Filters to categories above the specified category in the hierarchy.

Parameters

ParameterTypeDescription
categoryNameStringThe category API name

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryName is blank

Example

apex
.withDataCategory('Geography__c').above('USA__c')

aboveOrBelow

apex
global QRY_Builder.Builder aboveOrBelow(List<String> categoryNames)

Filters to categories above or below any of the specified categories in the hierarchy.

Parameters

ParameterTypeDescription
categoryNamesListThe category API names

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryNames is null or empty

Example

apex
.withDataCategory('Audience__c').aboveOrBelow(new List<String>{'External', 'Internal'})
apex
global QRY_Builder.Builder aboveOrBelow(String categoryName)

Filters to categories above or below the specified category in the hierarchy.

Parameters

ParameterTypeDescription
categoryNameStringThe category API name

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryName is blank

Example

apex
.withDataCategory('Audience__c').aboveOrBelow('External')

at

apex
global QRY_Builder.Builder at(List<String> categoryNames)

Filters to any of the specified categories.

Parameters

ParameterTypeDescription
categoryNamesListThe category API names

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryNames is null or empty

Example

apex
.withDataCategory('Geography__c').at(new List<String>{'USA__c', 'Canada__c'})
apex
global QRY_Builder.Builder at(String categoryName)

Filters to the exact specified category.

Parameters

ParameterTypeDescription
categoryNameStringThe category API name

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryName is blank

Example

apex
.withDataCategory('Geography__c').at('USA__c')

below

apex
global QRY_Builder.Builder below(List<String> categoryNames)

Filters to categories below any of the specified categories in the hierarchy.

Parameters

ParameterTypeDescription
categoryNamesListThe category API names

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryNames is null or empty

Example

apex
.withDataCategory('Product__c').below(new List<String>{'Electronics__c', 'Clothing__c'})
apex
global QRY_Builder.Builder below(String categoryName)

Filters to categories below the specified category in the hierarchy.

Parameters

ParameterTypeDescription
categoryNameStringThe category API name

Returns QRY_Builder.Builder — Builder for chaining

Throws

ExceptionDescription
IllegalArgumentExceptionif categoryName is blank

Example

apex
.withDataCategory('Product__c').below('Electronics__c')