Topics Class

Access information about topics, such as their descriptions, the number of people talking about them, related topics, and information about groups contributing to the topic. Update a topic’s name or description, merge topics, and add and remove topics from records and feed items.

ConnectApi

These methods are for Topics. All methods are static.

These methods in this class require Chatter and are subject to the per user, per namespace, per hour rate limit.

All other methods in this class count toward the Salesforce Platform total API request allocations, which are per org and span a 24-hour period.

Assign a topic to a record or feed item.

29.0

No

public static ConnectApi.Topic assignTopic(String communityId, String recordId, String topicId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

ID for a record or feed item.

topicId

Type: String

ID for a topic.

Type: ConnectApi.​Topic

Only users with the Assign Topics permission can add existing topics to records or feed items. Administrators must enable topics for objects before users can add topics to records of that object type.

Assign a topic to a record or feed item.

29.0

No

public static ConnectApi.Topic assignTopicByName(String communityId, String recordId, String topicName)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

The ID of the record or feed item to which to assign the topic.

topicName

Type: String

The name of a new or existing topic.

Type: ConnectApi.​Topic

Only users with the Assign Topics permission can add existing topics to records or feed items. Only users with the Create Topics permission can add new topics to records or feed items. Administrators must enable topics for objects before users can add topics to records of that object type.

Create a topic.

36.0

No

public static ConnectApi.Topic createTopic(String communityId, String name, String description)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

name

Type: String

The name of the topic.

description

Type: String

The description of the topic.

Type: ConnectApi.​Topic

Only users with the Create Topics permission can create a topic.

Create topic and article assignment rules by data category.

40.0

No

public static ConnectApi.TopicPage createTopicDataCategoryRules(String communityId, String dataCategoryGroup, String dataCategory, ConnectApi.TopicNamesInput topicNames)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

dataCategoryGroup

Type: String

The data category group used by articles.

dataCategory

Type: String

The data category used by articles.

topicNames

Type: ConnectApi.TopicNamesInput

A ConnectApi.TopicNamesInput object with the names of topics to assign to articles in a data category.

Type: ConnectApi.TopicPage

Delete a topic.

29.0

No

public static Void deleteTopic(String communityId, String topicId)

communityId

Type: String,

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

ID for a topic.

Type: Void

Only users with the Delete Topics or Modify All Data permission can delete topics.

Topic deletion is asynchronous. If a topic is requested before the deletion completes, the response is successful and the isBeingDeleted property of ConnectApi.Topic is true in version 33.0 and later. If a topic is requested after the deletion completes, the response is ConnectApi.NotFoundException.

Get information about the five groups that most recently contributed to a topic.

29.0

32.0

Yes

public static ConnectApi.ChatterGroupSummaryPage getGroupsRecentlyTalkingAboutTopic(String communityId, String topicId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

ID for a topic.

Type: ConnectApi.​Chatter​Group​SummaryPage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get up to five topics most recently used in a group.

29.0

32.0

Yes

public static ConnectApi.TopicPage getRecentlyTalkingAboutTopicsForGroup(String communityId, String groupId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

groupId

Type: String

ID for a group.

Type: ConnectApi.​TopicPage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get up to five topics most recently used by a user.

29.0

32.0

Yes

public static ConnectApi.TopicPage getRecentlyTalkingAboutTopicsForUser(String communityId, String userId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

Type: ConnectApi.​TopicPage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get up to five topics most closely related to a topic.

Two topics that are assigned to the same feed item at least three times are related.

29.0

32.0

No

public static ConnectApi.TopicPage getRelatedTopics(String communityId, String topicId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

ID for a topic.

Type: ConnectApi.​TopicPage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get a topic.

29.0

32.0

No

public static ConnectApi.Topic getTopic(String communityId, String topicId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

ID for a topic.

Type: ConnectApi.​Topic

Get topic and article assignment rules by data category.

40.0

No

public static ConnectApi.TopicPage getTopicDataCategoryRules(String communityId, String dataCategoryGroup, String dataCategory)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

dataCategoryGroup

Type: String

The data category group used by articles.

dataCategory

Type: String

The data category used by articles.

Type: ConnectApi.TopicPage

Get the first page of topics assigned to a record or feed item.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId, String recordId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

ID for a record or feed item.

Type: ConnectApi.​TopicPage

Administrators must enable topics for objects before users can add topics to records of that object type.

Get the first page of topics for the org or Experience Cloud site.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

Type: ConnectApi.​TopicPage

Get the first page of sorted topics for the org or community.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId, ConnectApi.TopicSort sortParam)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

sortParam

Type: ConnectApi.​TopicSort

Values are:

  • popularDesc—Sorts topics by popularity with the most popular first. This value is the default.
  • alphaAsc—Sorts topics alphabetically.

Type: ConnectApi.​TopicPage

Get a page of topics.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId, Integer pageParam, Integer pageSize)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

Type: ConnectApi.​TopicPage

Get a page of sorted topics.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId, Integer pageParam, Integer pageSize, ConnectApi.TopicSort sortParam)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

sortParam

Type: ConnectApi.​TopicSort

Values are:

  • popularDesc—Sorts topics by popularity with the most popular first. This value is the default.
  • alphaAsc—Sorts topics alphabetically.

Type: ConnectApi.​TopicPage

Get the sorted topics that match the search criteria.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId, String q, ConnectApi.TopicSort sortParam)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Specifies the string to search. The string must contain at least two characters, not including wildcards.

sortParam

Type: ConnectApi.​TopicSort

Values are:

  • popularDesc—Sorts topics by popularity with the most popular first. This value is the default.
  • alphaAsc—Sorts topics alphabetically.

Type: ConnectApi.​TopicPage

Get a page of topics that match the search criteria.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId, String q, Integer pageParam, Integer pageSize)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Specifies the string to search. The string must contain at least two characters, not including wildcards.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

Type: ConnectApi.​TopicPage

Get a page of sorted topics that match the search criteria.

29.0

32.0

No

public static ConnectApi.TopicPage getTopics(String communityId, String q, Integer pageParam, Integer pageSize, ConnectApi.TopicSort sortParam)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Specifies the string to search. The string must contain at least two characters, not including wildcards.

pageParam

Type: Integer

Number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

sortParam

Type: ConnectApi.​TopicSort

Values are:

  • popularDesc—Sorts topics by popularity with the most popular first. This value is the default.
  • alphaAsc—Sorts topics alphabetically.

Type: ConnectApi.​TopicPage

Get the topic that matches the exact, case-insensitive name.

33.0

33.0

No

public static ConnectApi.TopicPage getTopics(String communityId, String q, Boolean exactMatch)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Specifies the string to search. The string must contain at least two characters, not including wildcards.

exactMatch

Type: Boolean

Specify true to find a topic by its exact, case-insensitive name.

Type: ConnectApi.​TopicPage

Get the most recent renamed topic match, if there isn’t an exact match.

35.0

35.0

No

public static ConnectApi.TopicPage getTopicsOrFallBackToRenamedTopics(String communityId, String q, Boolean exactMatch, Boolean fallBackToRenamedTopics)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

q

Type: String

Specifies the string to search. The string must contain at least two characters, not including wildcards.

exactMatch

Type: Boolean

Specify true to find a topic by its exact, case-insensitive name or to find the most recent renamed topic match if there isn’t an exact match.

fallBackToRenamedTopics

Type: Boolean

Specify true and if there isn’t an exact match, the most recent renamed topic match is returned. If there are multiple renamed topic matches, only the most recent is returned. If there are no renamed topic matches, an empty collection is returned.

Type: ConnectApi.​TopicPage

Get up to a specified number of suggested topics for a record or feed item.

29.0

No

public static ConnectApi.TopicSuggestionPage getTopicSuggestions(String communityId, String recordId, Integer maxResults)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

ID for a record or feed item.

maxResults

Type: Integer

Maximum number of topic suggestions that get returned. The default is 5. Value must be greater than 0 and less than or equal to 25.

Type: ConnectApi.​TopicSuggestionPage

Administrators must enable topics for objects before users can see suggested topics for records of that object type.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get suggested topics for a record or feed item.

29.0

No

public static ConnectApi.TopicSuggestionPage getTopicSuggestions(String communityId, String recordId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

ID for a record or feed item.

Type: ConnectApi.​TopicSuggestionPage

Administrators must enable topics for objects before users can see suggested topics for records of that object type.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get up to a specified number of suggested topics for a string of text.

29.0

No

public static ConnectApi.TopicSuggestionPage getTopicSuggestionsForText(String communityId, String text, Integer maxResults)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

text

Type: String

String of text.

maxResults

Type: Integer

Maximum number of topic suggestions that get returned. The default is 5. Value must be greater than 0 and less than or equal to 25.

Type: ConnectApi.​TopicSuggestionPage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get suggested topics for a string of text.

29.0

No

public static ConnectApi.TopicSuggestionPage getTopicSuggestionsForText(String communityId, String text)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

text

Type: String

String of text.

Type: ConnectApi.​TopicSuggestionPage

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get trending topics for the org or Experience Cloud site.

29.0

32.0

No

public static ConnectApi.TopicPage getTrendingTopics(String communityId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

Type: ConnectApi.​TopicPage

The more frequently people add a specific topic to their posts and comments and comment on or like posts with the same topic over a short period, the more likely it is to become a trending topic. For example, if your coworkers are attending the upcoming Dreamforce conference and have started discussing it in Chatter, you might see a trending topic for Dreamforce. A trending topic is not solely based on popularity and usually relates to a one-time or infrequent event that has a spike in activity, such as a conference or a project deadline.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Get up to a specified number of trending topics for the org or Experience Cloud site.

29.0

32.0

No

public static ConnectApi.TopicPage getTrendingTopics(String communityId, Integer maxResults)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

maxResults

Type: Integer

Maximum number of topic suggestions that get returned. The default is 5. Value must be greater than 0 and less than or equal to 25.

Type: ConnectApi.​TopicPage

The more frequently people add a specific topic to their posts and comments and comment on or like posts with the same topic over a short period, the more likely it is to become a trending topic. For example, if your coworkers are attending the upcoming Dreamforce conference and have started discussing it in Chatter, you might see a trending topic for Dreamforce. A trending topic is not solely based on popularity and usually relates to a one-time or infrequent event that has a spike in activity, such as a conference or a project deadline.

To test code that uses this method, use the matching set test method (prefix the method name with setTest). Use the set test method with the same parameters or the code throws an exception.

See Also

Merge up to five secondary topics with a primary topic.

33.0

No

public static ConnectApi.Topic mergeTopics(String communityId, String topicId, List<String> idsToMerge)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

The ID for the primary topic for the merge. If this topic is a managed topic, it retains its topic type, topic images, and children topics.

idsToMerge

Type: List<String>

A list of up to five comma-separated secondary topic IDs to merge with the primary topic. If any of the secondary topics are navigational or featured topics, they lose their topic type, topic images, and children topics. Their feed items are reassigned to the primary topic. If you merge a topic with a content topic, the content associations are preserved. If you merge a topic with an inactive endorsee, the endorsement isn’t mapped to the primary topic.

Type: ConnectApi.​Topic

Only users with the Delete Topics or Modify All Data permission can merge topics.

Reassign topic and article assignment rules by data category by deleting the existing rules and creating new rules.

40.0

No

public static ConnectApi.TopicPage reassignTopicDataCategoryRules(String communityId, String dataCategoryGroup, String dataCategory, ConnectApi.TopicNamesInput topicNames)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

dataCategoryGroup

Type: String

The data category group used by articles.

dataCategory

Type: String

The data category used by articles.

topicNames

Type: ConnectApi.TopicNamesInput

A ConnectApi.TopicNamesInput object with the names of topics to reassign to articles in a data category.

Type: ConnectApi.TopicPage

Reassign all the topics on a record or feed item, that is, remove all the assigned topics on a record or feed item and add topics. Optionally, provide a list of suggested topics to assign to a record or feed item to improve future topic suggestions.

35.0

No

public static ConnectApi.TopicPage reassignTopicsByName(String communityId, String recordId, ConnectApi.TopicNamesInput topicNames)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

The ID of the record or feed item to which to assign the topic.

topicNames

Type: ConnectApi.TopicNamesInput

A list of topics to replace the currently assigned topics. Optionally, a list of suggested topics to assign to improve future topic suggestions.

Type: ConnectApi.​TopicPage

Only users with the Assign Topics permission can remove topics from records or feed items and add existing topics to records or feed items. Only users with the Create Topics permission can add new topics to records or feed items. Administrators must enable topics for objects before users can add topics to records of that object type.

Remove a topic from a record or feed item.

29.0

No

public static Void unassignTopic(String communityId, String recordId, String topicId)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

ID for a record or feed item.

topicId

Type: String

ID for a topic.

Type: Void

Only users with the Assign Topics permission can remove topics from feed items or records. Administrators must enable topics for objects before users can add topics to records of that object type.

Update the description or name of a topic or merge up to five secondary topics with a primary topic.

29.0

No

public static ConnectApi.Topic updateTopic(String communityId, String topicId, ConnectApi.TopicInput topic)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

ID for a topic.

topic

Type: ConnectApi.TopicInput

A ConnectApi.TopicInput object containing the name and description of the topic or up to five comma-separated secondary topic IDs to merge with the primary topic.

Type: ConnectApi.​Topic

Only users with the Edit Topics or Modify All Data permission can update topic names and descriptions. Only users with the Delete Topics or Modify All Data permission can merge topics.

Assign topics to articles and unassign topics from articles in a data category.

40.0

No

public static ConnectApi.TopicPage updateTopicsForArticlesInDataCategory(String communityId, String dataCategoryGroup, String dataCategory, ConnectApi.ArticleTopicAssignmentJobInput articleTopicAssignmentJob)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

dataCategoryGroup

Type: String

The data category group used by articles.

dataCategory

Type: String

The data category used by articles.

articleTopicAssignmentJob

Type: ConnectApi.ArticleTopicAssignmentJobInput

A ConnectApi.ArticleTopicAssignmentJobInput object that indicates the operation to take on which topics.

Type: ConnectApi.TopicPage

These test methods are for Topics. All methods are static.

For information about using these methods to test your ConnectApi code, see Testing ConnectApi Code.

Register a ConnectApi.ChatterGroupSummaryPage object to be returned when the matching ConnectApi.getGroupsRecentlyTalkingAboutTopic method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetGroupsRecentlyTalkingAboutTopic(String communityId, String topicId, ConnectApi.ChatterGroupSummaryPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

ID for a topic.

result

Type: ConnectApi.​Chatter​Group​SummaryPage

Object containing test data.

Type: Void

See Also

Register a ConnectApi.​TopicPage object to be returned when the matching ConnectApi.getRecentlyTalkingAboutTopicsForGroup method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetRecentlyTalkingAboutTopicsForGroup(String communityId, String groupId, ConnectApi.​TopicPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

groupId

Type: String

ID for a group.

result

Type: ConnectApi.​TopicPage

Object containing test data.

Type: Void

See Also

Register a ConnectApi.​TopicPage object to be returned when the matching ConnectApi.getRecentlyTalkingAboutTopicsForUser method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetRecentlyTalkingAboutTopicsForUser(String communityId, String userId, ConnectApi.TopicPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

userId

Type: String

ID for a user.

result

Type: ConnectApi.​TopicPage

Specify the test topics page.

Type: Void

See Also

Register a ConnectApi.TopicPage object to be returned when the matching ConnectApi.getRelatedTopics method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetRelatedTopics(String communityId, String topicId, ConnectApi.TopicPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

topicId

Type: String

ID for a topic.

result

Type: ConnectApi.​TopicPage

Object containing test data.

Type: Void

See Also

Register a ConnectApi.TopicSuggestionPage object to be returned when the matching ConnectApi.getTopicSuggestions method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetTopicSuggestions(String communityId, String recordId, Integer maxResults, ConnectApi.TopicSuggestionPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

ID for a record or feed item.

maxResults

Type: Integer

Maximum number of topic suggestions that get returned. The default is 5. Value must be greater than 0 and less than or equal to 25.

result

Type: ConnectApi.​TopicSuggestionPage

Specify the test topic suggestions page.

Type: Void

See Also

Register a ConnectApi.TopicSuggestionPage object to be returned when the matching ConnectApi.getTopicSuggestions method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetTopicSuggestions(String communityId, String recordId, ConnectApi.​TopicSuggestionPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

recordId

Type: String

ID for a record or feed item.

result

Type: ConnectApi.​TopicSuggestionPage

Object containing test data.

Type: Void

See Also

Register a ConnectApi.TopicSuggestionPage object to be returned when the matching ConnectApi.getTopicSuggestionsForText method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetTopicSuggestionsForText(String communityId, String text, Integer maxResults, ConnectApi.TopicSuggestionPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

text

Type: String

String of text.

maxResults

Type: Integer

Maximum number of topic suggestions that get returned. The default is 5. Value must be greater than 0 and less than or equal to 25.

result

Type: ConnectApi.​TopicSuggestionPage

Object containing test data.

Type: Void

See Also

Register a ConnectApi.TopicSuggestionPage object to be returned when the matching ConnectApi.getTopicSuggestionsForText method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetTopicSuggestionsForText(String communityId, String text, ConnectApi.TopicSuggestionPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

text

Type: String

String of text.

result

Type: ConnectApi.​TopicSuggestionPage

Object containing test data.

Type: Void

See Also

Register a ConnectApi.TopicPage object to be returned when the matching ConnectApi.getTrendingTopics method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetTrendingTopics(String communityId, ConnectApi.TopicPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

result

Type: ConnectApi.​TopicPage

Object containing test data.

Type: Void

See Also

Register a ConnectApi.TopicPage object to be returned when the matching ConnectApi.getTrendingTopics method is called in a test context. Use the method with the same parameters or you receive an exception.

29.0

public static Void setTestGetTrendingTopics(String communityId, Integer maxResults, ConnectApi.TopicPage result)

communityId

Type: String

ID for an Experience Cloud site, internal, or null.

maxResults

Type: Integer

Maximum number of topic suggestions that get returned. The default is 5. Value must be greater than 0 and less than or equal to 25.

result

Type: ConnectApi.​TopicPage

Object containing test data.

Type: Void

See Also