+ 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);