0

I started using the Knowledge base and i want to pull out all the knowledge base category group names from it. 

I am using the following SOQL statement:

Select Id, Question__c, Answer__c, (Select DataCategoryName, DataCategoryGroupName FROM DataCategorySelections) FROM Knowledge__kav

But somehow the soql inside the soql prints out the unique name of the data category group instead of the normal name.

Any advices how can i fix this?

Thanks,

Darko

1

You can use Rest API to get data category group labels. Try GET request to below URI as:

/services/data/v43.0/support/dataCategoryGroups/<Your DataCategoryGruop Name>/dataCategories/All?sObjectName=KnowledgeArticleVersion

You will be getting details including name, label and its child category details. Parse the JSON response and do your logic.

Sample response looks like:

{
  "childCategories" : [ {
    "childCategories" : null,
    "label" : "Demo 1",
    "name" : "Demo_1",
    "url" : "/services/data/v43.0/support/dataCategoryGroups/Test/dataCategories/Demo_1?sObjectName=KnowledgeArticleVersion"
  }, {
    "childCategories" : null,
    "label" : "Test1",
    "name" : "Test1",
    "url" : "/services/data/v43.0/support/dataCategoryGroups/Test/dataCategories/Test1?sObjectName=KnowledgeArticleVersion"
  }, {
    "childCategories" : null,
    "label" : "Test2",
    "name" : "Test2",
    "url" : "/services/data/v43.0/support/dataCategoryGroups/Test/dataCategories/Test2?sObjectName=KnowledgeArticleVersion"
  } ],
  "label" : "All",
  "name" : "All",
  "url" : "/services/data/v43.0/support/dataCategoryGroups/Test/dataCategories/All?sObjectName=KnowledgeArticleVersion"
}
  • 1
    Thanks @Reshma your answer helped me solve my problem. – Darko Todorovski Dec 4 '18 at 10:23
0

I found a better and easier solution to this without using a restAPI after reading the knowledge dev guide.

The solution was easier than it appear. All I needed to do is toLabel()

Select Id, Question__c, Answer__c, (Select toLabel(DataCategoryName), toLabel(DataCategoryGroupName) FROM DataCategorySelections) FROM Knowledge__kav

Cheers,

Darko

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.