function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ranjith PunneliRanjith Punneli 

getChildCategories() not working

Hi All,

 

Anyone please help me to access child categories of a category group. Code below

 

List <DataCategoryGroupSobjectTypePair> pairs = new List<DataCategoryGroupSobjectTypePair>();
DataCategoryGroupSobjectTypePair pair = new DataCategoryGroupSobjectTypePair();
pair.setSobject('KnowledgeArticleVersion');
pair.setDataCategoryGroupName('CustomerType');
pairs.add(pair);
List<Schema.DescribeDataCategoryGroupStructureResult>results = Schema.describeDataCategoryGroupStructures(pairs, true);
System.debug('*****'+results);
DataCategory [] toplevelCategories = results[0].getTopCategories();
DataCategory toplevelCategoryAll = toplevelCategories[0];
System.debug('*****'+toplevelCategoryAll );
List<Schema.DataCategory> childCategories = toplevelCategoryAll.getChildCategories();
System.debug('*****'+childCategories[0] );

 

I have 5 child category in category group "All". However, getChildCategories() is returning null. My profile has permission to view all child category. Please help me out.

 

Best Answer chosen by Admin (Salesforce Developers) 
Ranjith PunneliRanjith Punneli

List<Schema.DescribeDataCategoryGroupStructureResult>results = Schema.describeDataCategoryGroupStructures(pairs, false);