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
PathikritPathikrit 

Method does not exist or incorrect signature: ConnectApi.Topic.assignTopicByName

Hi All,

I am getting this error when I try to create a Topic through Apex.

Method does not exist or incorrect signature: ConnectApi.Topic.assignTopicByName

Here is my code:
ConnectApi.Topic.assignTopicByName(null,f.Id,'Test1');
I can't figure out the error here...please help
 
Gaurav KheterpalGaurav Kheterpal
Have you tried sending a valid community Id as first parameter to see if it makes a difference?

Something like
 
ConnectApi.Topics.assignTopicByName(communityId, feedItemId, 'Test1');
ConnectApi.Topics.assignTopicByName(communityId, feedItemId, 'Test2');
ConnectApi.Topics.assignTopicByName(communityId, feedItemId, 'Test3');
If the issue is not resolved, share your code and I may be able to help.

If my answer helps resolve your query, please mark it as the 'Best Answer' to benefit others and improve the overall quality of Discussion Forums.
 
PathikritPathikrit
Hi Gaurav,

My objective is to add a topic to a automated Chatter Message (i.e. FeedTrackedChange). Here is my code..
listFeedTrackedChange=[select Id, ParentId,CreatedDate  from custom_object__feed where parentId=:customobjectId];
        if(!listFeedTrackedChange.isEmpty()){
            for(custom_Object__feed f: listFeedTrackedChange){
                if(f.CreatedDate>=lastModifiedOn.addMinutes(-1)){
                    ConnectApi.Topic.assignTopicByName(null,f.Id,'Test1');
               }
           }
Gaurav KheterpalGaurav Kheterpal
What API version are you on? The Connect API has gone some changes in v30

If my answer helps resolve your query, please mark it as the 'Best Answer' to benefit others and improve the overall quality of Discussion Forums.