function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JO_DevJO_Dev 

SOQL Query for specific data categories

How do I write a SOQL query for data categories?
Best Answer chosen by JO_Dev
BALAJI CHBALAJI CH
Hi Jared Owens,

Data categories are used to classify records. In SOQL, you can use the Article__DataCategorySelection or QuestionDataCategorySelection objects. You can also build a relationship query with the DataCategorySelectionsrelationship name in a FROM clause.
Imagine an Offer article type. The following query returns the ID of any categorization associated with an offer and the ID of the categorized article.
SELECT Id,ParentId
FROM Offer__DataCategorySelection

The following example uses the DataCategorySelections relationship name to build a relationship query that returns the ID of published offers and the ID of all the categorizations associated to these offers.
SELECT Id, Title
  (
    SELECT Id
    FROM DataCategorySelections
  )
FROM Offer__kav WHERE publishStatus='online';

Also please find below links.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_with_datacategory.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_with_datacategory_examples.htm

http://salesforce.stackexchange.com/questions/75325/query-on-data-categories

Best Regards,
BALAJI

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Hi Jared Owens,

I see you posted multiple post for SOQL. I will suggest you please work on below trailhead module to learn about SOQL.
1)https://developer.salesforce.com/trailhead/module/database_basics_dotnet

Please check below post. I hope that will help you
1) https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com
2) https://sivatejaforce.wordpress.com/2011/02/11/a-deeper-look-at-soql-and-relationship-queries/
3) http://womencodeheroes.com/2015/04/cooking-with-code-a-sweet-intro-to-soql-part-two/

Let us know if this will help you
Thanks
Amit Chaudhary
BALAJI CHBALAJI CH
Hi Jared Owens,

Data categories are used to classify records. In SOQL, you can use the Article__DataCategorySelection or QuestionDataCategorySelection objects. You can also build a relationship query with the DataCategorySelectionsrelationship name in a FROM clause.
Imagine an Offer article type. The following query returns the ID of any categorization associated with an offer and the ID of the categorized article.
SELECT Id,ParentId
FROM Offer__DataCategorySelection

The following example uses the DataCategorySelections relationship name to build a relationship query that returns the ID of published offers and the ID of all the categorizations associated to these offers.
SELECT Id, Title
  (
    SELECT Id
    FROM DataCategorySelections
  )
FROM Offer__kav WHERE publishStatus='online';

Also please find below links.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_with_datacategory.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_with_datacategory_examples.htm

http://salesforce.stackexchange.com/questions/75325/query-on-data-categories

Best Regards,
BALAJI
This was selected as the best answer