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?

  • It may be that DataCategoryName is the real culprit. If you go to DataCategorySetup, do you see Latin America as an actual subcategory of what you end up using from results[0]? – Adrian Larson Aug 18 '16 at 10:52
  • 1
    got it. i was setting up latin america , it should have an underscore sign. thanks you – Venkatz Aug 18 '16 at 10:57

You might be getting this error based on DataCategoryName, not DataCategoryGroupName. Double-check that Latin America is a valid category for the category group you selected based on results[0].


The error message is misleading in a way

Salesforce takes the value in the DataCategoryName and then looks to see if it can be found in the associated DataCategoryGroupName. If it doesn't find it, the error

INVALID_DATA_CATEGORY_GROUP_REFERENCE, invalid data category group referenced

is generated which makes you think you screwed up in the specification of DataCategoryGroupName, or swapped data category names for groups and vice-versa.

A typical cause of this error is that DataCategoryName is the Data Categories API name, so, if using Apex or Data Loader, it is easy to forget this, especially if you are using the recommended Data Category Groups:

  • Products
  • Geos
  • Customer Types

where real world Data Category Names (labels) may have spaces such as in your OP Latin America. Its API name is Latin_America

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.