I am trying to assign data categories to knowledge base articles records. I am using articlename_DataCategorySelection to define the assignment and then to inset it. The object to be inserted as follows:
DescribeDataCategoryGroupResult[] results = Schema.describeDataCategoryGroups(
new String[] { 'KnowledgeArticleVersion'}
);
tempCat = new MSDS__DataCategorySelection ();
tempCat.DataCategoryGroupName = results[0].getName(); // key line
tempCat.DataCategoryName = 'Latin America'; //m.Category_Path__c;
tempCat.ParentId = m.id;
Above, results[0]
is of type DescribeDataCategoryGroupResult
--that contains data category group description. but it is not allowing me to insert the record successfully.
While running the code above, I get an error:
INVALID_DATA_CATEGORY_GROUP_REFERENCE, invalid data category group referenced
It seems the DataCategoryGroupName
is not handled properly. Does anyone know what value to assign to that field?
DataCategoryName
is the real culprit. If you go toDataCategorySetup
, do you seeLatin America
as an actual subcategory of what you end up using fromresults[0]
?