A data category selection represents a data category that classifies a question. This object can be used to associate a question with a data category from a data category group or to query the categorization for a question.
create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve()
To create, read or update data category selection, you must have create, read or update permission on the categorized question. Users who can update question can also delete its category selection. Users who can create questions can only select categories visible to their role.
| Field Name | Details |
|---|---|
| DataCategoryGroupName |
|
| DataCategoryName |
|
| ParentId |
Every question can be categorized in a data category. You can use the QuestionDataCategorySelection object to query and manage question categorization. Client applications can create categorization for a question. They can also delete, query, and retrieve question categorization.
In the following example, the selectCategory method adds a category to a question data category selection. The retrieveCategorySelections method returns all the categories from a question data category selection.
public void selectCategory(ID parentId, String categoryGroupName, String categoryName) { try { QuestionDataCategorySelection categorySelection = new QuestionDataCategorySelection(); categorySelection.setParentId(parentId); categorySelection.setDataCategoryGroupName(categoryGroupName); categorySelection.setDataCategoryName(categoryName); binding.create(new SObject[]{categorySelection}); } catch (RemoteException e) { System.out.println("An unexpected error has occurred." + e.getMessage()); } } public String[] retrieveCategorySelections(String parentId) { QueryResult qr = null; try { qr = binding.query("SELECT DataCategoryName FROM QuestionDataCategorySelection WHERE Id = '" + parentId + "'"); } catch (RemoteException e) { System.out.println("An unexpected error has occurred." + e.getMessage()); } String[] categoryNames = new String[qr.getRecords().length]; for (int index = 0; index < qr.getRecords().length; index++) { categoryNames[index] = ((QuestionDataCategorySelection)qr.getRecords()[index]).getDataCategoryName(); } return categoryNames; }
Salesforce Knowledge uses a similar object for article data category selection. See Article Type__DataCategorySelection for SOQL examples using this object.