+ Start a Discussion
hari.phari.p 

How to create a Sub topic for a Navigational Topic with Apex code for a community

Hi, I am trying to create the subtopics for a navigational topic in community witht apex code.

ConnectApi.ManagedTopicType managedTopicType=connectApi.ManagedTopicType.Navigational;
ConnectApi.ManagedTopics.createManagedTopicByName('0DB55000000CarKGAS', 'Test Topic',managedTopicType ,'0TO550000008ZlfGAE');

When I execute this code it gives me this error.
Line: 256, Column: 1
ConnectApi.ConnectApiException: Illegal value for parameter: 'parentId': 0TO550000008ZlfGAE

As it showes line 256, I don't even have more than two line of code here in developer console unanimus block. So it seams we are getting this error from the main class. Can any one suggest what wrong in it. Thanks 
SandhyaSandhya (Salesforce Developers) 
Hi,

I think the issue is with parent Id as I see in the below link.
Make a note of the ID of the navigational managed topic you want to be the parent topic. It has a prefix of 0mt.

https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/quickreference_create_topic_hierarchy.htm
 
Thanks and Regards
Sandhya