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
Praneetha MurakondaPraneetha Murakonda 

How to get sub topic related to selected Topic in apex?

Hi All,

I' creating a question from community. Question can be created  from either Topic or Group. When ever i'm creating question there is an option to add sub topic related to selected Topic. I need to distinguish between primary topic and subtopic. How can i query subtopic related to selected primary topic in apex.

Please let me know if there is any workaround.

Thanks!

rajat Maheshwari 6rajat Maheshwari 6

Hi Praneetha,

Please use below soql query : - 

List<PrimaryTopic> lst_Primary = new List<PrimaryTopic>([Select Id,fields,(Select Id,fields from subTopic__r) from primaryTopic]);

Something as shown in above will be used.

Please let me know, if it works :)

Thanks
Rajat Maheshwari
rajatzmaheshwari@gmail.com

Praneetha MurakondaPraneetha Murakonda

Hi rajat,

Thanks for reply. Actually i need subtopic related to Topic (Standard object).

I need to get Topic and SubTopic related to feedItem. I'm getting Topic Id related to FeedItem from TopicAssignment object like below.

List<TopicAssignment> myFeedItemFeedAssignments = [SELECT Id, NetworkId, TopicId, Topic.Name, EntityId
                                                   FROM TopicAssignment
                                                   EntityId IN  : feedItemId];
                                                   
I will get TopicId but not able to get SubTopics. I didn't find any field on Topic object related to subtopic.  Please suggest if there is any way to get SubTopics related to Topic                                        

Sudipta SamalSudipta Samal
Hi Praneetha, 

Did you get any solution for sub topic ? 

Thanks,
Sudipta 
Amardeep ChauhanAmardeep Chauhan
Do we have Soluction for above question ?  I need help on same.
Ganesh SirpuramGanesh Sirpuram
Did any one get soluction for above question ?  Please help me.