Newer Version Available

This content describes an older version of this product. View Latest

Mentions Class

Access information about mentions. A mention is an “@” character followed by a user or group name. When a user or group is mentioned, they receive a notification.

Namespace

ConnectApi

Mentions Methods

The following are methods for Mentions. All methods are static.

getMentionCompletions(String, String, String)

Returns the first page of possible users and groups to mention in a feed item body or comment body. A mention is an “@” character followed by a user or group name. When a user or group is mentioned, they receive a notification.

API Version

29.0

Signature

public static ConnectApi.MentionCompletionPage getMentionCompletions (String communityId, String q, String contextId)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
q
Type: String
A search term. Searches for matching user and group names. To search for a user, a minimum of 1 character is required. To search for a group, a minimum of 2 characters is required. This parameter does not support wildcards.
contextId
Type: String
A feed item ID (for a mention in a comment) or a feed subject ID (for a mention in a feed item) that narrows search results, with more useful results listed first.

Usage

Call this method to generate a page of proposed mentions that a user can choose from when they enter characters in a feed item body or a comment body.

getMentionCompletions(String, String, String, ConnectApi.MentionCompletionType, Integer, Integer)

Returns the specified page number of mention proposals of the specified mention completion type: All, User, or Group. A mention is an “@” character followed by a user or group name. When a user or group is mentioned, they receive a notification.

API Version

29.0

Signature

public static ConnectApi.Mentions getMentionCompletions (String communityId, String q, String contextId, ConnectApi.MentionCompletionType type, Integer pageParam, Integer pageSize)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
q
Type: String
A search term. Searches for matching user and group names. To search for a user, a minimum of 1 character is required. To search for a group, a minimum of 2 characters is required. This parameter does not support wildcards.
contextId
Type: String
A feed item ID (for a mention in a comment) or a feed subject ID (for a mention in a feed item) that narrows search results, with more useful results listed first.
type
Type: ConnectApi.MentionCompletionType
Specifies the type of mention completion:
  • All—All mention completions, regardless of the type of record to which the mention refers.
  • Group—Mention completions for groups.
  • User—Mention completions for users.
pageParam
Type: String
Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
pageSize
Type: String
Specifies the number of items per page. Valid values are between 1 and 100. If you pass in null, the default size is 25.

Usage

Call this method to generate a page of proposed mentions that a user can choose from when they enter characters in a feed item body or a comment body.

getMentionValidations(String, String, List<String>, ConnectApi.FeedItemVisibilityType)

Information about whether the specified mentions are valid for the context user.

API Version

29.0

Signature

public static ConnectApi.Mentions getMentionValidations(String communityId, String parentId, List<String> recordIds, ConnectApi.FeedItemVisibilityType visibility)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
parentId
Type: String
The feed item parent ID (for new feed items) or feed item ID (for comments).
recordIds
Type: List<String>
A comma separated list of IDs to be mentioned. The maximum value is 25.
visibility
Type: ConnectApi.FeedItemVisibilityType
Specifies the type of users who can see a feed item.
  • AllUsers—Visibility is not limited to internal users.
  • InternalUsers—Visibility is limited to internal users.

Usage

Call this method to check whether the record IDs returned from a call to ConnectApi.Mentions.getMentionCompletions are valid for the context user. For example, the context user can’t mention private groups he doesn’t belong to. If such a group were included in the list of mention validations, the ConnectApi.MentionValidations.hasErrors property would be true and the group would have a ConnectApi.MentionValidation.valdiationStatus of Disallowed.

setTestGetMentionCompletions(String, String, String, ConnectApi.MentionCompletionPage)

Registers a ConnectApi.MentionCompletionPage object to be returned when getMentionCompletions(String, String, String) is called in a test context.

API Version

29.0

Signature

public static Void setTestGetMentionCompletions (String communityId, String q, String contextId, ConnectApi.MentionCompletionPage result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
q
Type: String
A search term. Searches for matching user and group names. To search for a user, a minimum of 1 character is required. To search for a group, a minimum of 2 characters is required. This parameter does not support wildcards.
contextId
Type: String
A feed item ID (for a mention in a comment) or a feed subject ID (for a mention in a feed item) that narrows search results, with more useful results listed first.
result
Type: ConnectApi.​MentionCompletion​Page Class
A ConnectApi.MentionCompletionPage object containing test data.

Return Value

Type: Void

setTestGetMentionCompletions(String, String, String, ConnectApi.MentionCompletionType, Integer, Integer, ConnectApi.MentionCompletionPage)

Registers a ConnectApi.MentionCompletionPage object to be returned when getMentionCompletions(String, String, String, ConnectApi.MentionCompletionType, Integer, Integer) is called in a test context.

API Version

29.0

Signature

public static Void setTestGetMentionCompletions (String communityId, String q, String contextId, ConnectApi.MentionCompletionType type, Integer pageParam, Integer pageSize, ConnectApi.MentionCompletionPage result)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
q
Type: String
A search term. Searches for matching user and group names. To search for a user, a minimum of 1 character is required. To search for a group, a minimum of 2 characters is required. This parameter does not support wildcards.
contextId
Type: String
A feed item ID (for a mention in a comment) or a feed subject ID (for a mention in a feed item) that narrows search results, with more useful results listed first.
type
Type: ConnectApi.MentionCompletionType
Specifies the type of mention completion:
  • All—All mention completions, regardless of the type of record to which the mention refers.
  • Group—Mention completions for groups.
  • User—Mention completions for users.
pageParam
Type: String
Specifies the number of the page you want returned. Starts at 0. If you pass in null or 0, the first page is returned.
pageSize
Type: String
Specifies the number of items per page. Valid values are between 1 and 100. If you pass in null, the default size is 25.
result
Type: ConnectApi.​MentionCompletion​Page Class
A ConnectApi.MentionCompletionPage object containing test data.

Return Value

Type: Void