Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
CommunityModeration Class
Namespace
CommunityModeration Methods
All methods in this class require Chatter and are subject to the per user, per namespace, per hour rate limit.
addFlagToComment(communityId, commentId)
API Version
29.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- commentId
- Type: String
- ID for a comment.
Return Value
Usage
addFlagToComment(communityId, commentId, visibility)
API Version
30.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Usage
addFlagToComment(communityId, commentId, type)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId, ConnectApi.CommunityFlagType type)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
Return Value
Usage
addFlagToComment(communityId, commentId, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId, String note)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- commentId
- Type: String
- ID for a comment.
- note
- Type: String
- A note of up to 4,000 characters about the flag.
Return Value
Usage
addFlagToComment(communityId, commentId, type, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId, ConnectApi.CommunityFlagType type, String note)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
note
Type: String
A note of up to 4,000 characters about the flag.
Return Value
Usage
addFlagToComment(communityId, commentId, type, visibility)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId, ConnectApi.CommunityFlagType type, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Usage
addFlagToComment(communityId, commentId, visibility, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId, ConnectApi.CommunityFlagVisibility visibility, String note)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
note
Type: String
A note of up to 4,000 characters about the flag.
Return Value
Usage
To add a flag to a comment, Allow members to flag content must be selected for an Experience Cloud site.
addFlagToComment(communityId, commentId, type, visibility, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToComment(String communityId, String commentId, ConnectApi.CommunityFlagType type, ConnectApi.CommunityFlagVisibility visibility, String note)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
note
Type: String
A note of up to 4,000 characters about the flag.
Return Value
Usage
To add a flag to a comment, Allow members to flag content must be selected for an Experience Cloud site.
addFlagToFeedElement(communityId, feedElementId)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedElementId
- Type: String
- ID of the feed element.
Return Value
Type: ConnectApi.ModerationCapability
If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.
Usage
addFlagToFeedElement(communityId, feedElementId, visibility)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types. One of these values:
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Type: ConnectApi.ModerationCapability
If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.
Usage
addFlagToFeedElement(communityId, feedElementId, type)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagType type)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
Return Value
Usage
To add a flag to a feed element, Allow members to flag content must be selected for an Experience Cloud site.
addFlagToFeedElement(communityId, feedElementId, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId, String note)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedElementId
- Type: String
- ID of the feed element.
- note
- Type: String
- A note of up to 4,000 characters about the flag.
Return Value
Usage
To add a flag to a feed element, Allow members to flag content must be selected for an Experience Cloud site.
addFlagToFeedElement(communityId, feedElementId, type, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagType type, String note)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
note
Type: String
A note of up to 4,000 characters about the flag.
Return Value
Usage
To add a flag to a feed element, Allow members to flag content must be selected for an Experience Cloud site.
addFlagToFeedElement(communityId, feedElementId, type, visibility)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagType type, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types. One of these values:
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Usage
To add a flag to a feed element, Allow members to flag content must be selected for an Experience Cloud site.
addFlagToFeedElement(communityId, feedElementId, visibility, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagVisibility visibility, String note)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types. One of these values:
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
note
Type: String
A note of up to 4,000 characters about the flag.
Return Value
Usage
To add a flag to a feed element, Allow members to flag content must be selected for an Experience Cloud site.
addFlagToFeedElement(communityId, feedElementId, type, visibility, note)
API Version
38.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability addFlagToFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagType type, ConnectApi.CommunityFlagVisibility visibility, String note)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
type
Type: ConnectApi.CommunityFlagType
Type of moderation flag.
- FlagAsInappropriate—Flag for inappropriate content.
- FlagAsSpam—Flag for spam.
If a type isn’t specified, it defaults to FlagAsInappropriate.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types. One of these values:
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
note
Type: String
A note of up to 4,000 characters about the flag.
Return Value
Usage
To add a flag to a feed element, Allow members to flag content must be selected for an Experience Cloud site.
getFlagsOnComment(communityId, commentId)
API Version
29.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags getFlagsOnComment(String communityId, String commentId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- commentId
- Type: String
- ID for a comment.
Return Value
Usage
getFlagsOnComment(communityId, commentId, visibility)
API Version
30.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags getFlagsOnComment(String communityId, String commentId, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Usage
getFlagsOnComment(communityId, commentId, pageSize, pageParam)
API Version
40.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags getFlagsOnComment(String communityId, String commentId, Integer pageSize, String pageParam)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- commentId
- Type: String
- ID for a comment.
- pageSize
- Type: Integer
- Specifies the number of items per page. Valid values are from 1 through 100. The default size is 0.
- pageParam
- Type: String
- Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
Return Value
Usage
getFlagsOnComment(communityId, commentId, visibility, pageSize, pageParam)
API Version
40.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags getFlagsOnComment(String communityId, String commentId, ConnectApi.CommunityFlagVisibility visibility, Integer pageSize, String pageParam)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
commentId
Type: String
ID for a comment.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. The default size is 0.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
Return Value
Usage
getFlagsOnFeedElement(communityId, feedElementId)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability getFlagsOnFeedElement(String communityId, String feedElementId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedElementId
- Type: String
- ID of the feed element.
Return Value
Type: ConnectApi.ModerationCapability
If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.
Usage
getFlagsOnFeedElement(communityId, feedElementId, visibility)
API Version
31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability getFlagsOnFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types. One of these values:
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Type: ConnectApi.ModerationCapability
If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.
Usage
getFlagsOnFeedElement(communityId, feedElementId, pageParam, pageSize)
API Version
40.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability getFlagsOnFeedElement(String communityId, String feedElementId, String pageParam, Integer pageSize)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedElementId
- Type: String
- ID of the feed element.
- pageParam
- Type: String
- Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
- pageSize
- Type: Integer
- Specifies the number of items per page. Valid values are from 1 through 100. The default size is 0.
Return Value
Type: ConnectApi.ModerationCapability
If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.
Usage
getFlagsOnFeedElement(communityId, feedElementId, visibility, pageSize, pageParam)
API Version
40.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationCapability getFlagsOnFeedElement(String communityId, String feedElementId, ConnectApi.CommunityFlagVisibility visibility, Integer pageSize, String pageParam)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedElementId
Type: String
ID of the feed element.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
pageSize
Type: Integer
Specifies the number of items per page. Valid values are from 1 through 100. The default size is 0.
pageParam
Type: String
Page token to use to view the page. Page tokens are returned as part of the response class, for example, currentPageToken or nextPageToken. If you pass in null, the first page is returned.
Return Value
Type: ConnectApi.ModerationCapability
If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.
Usage
removeFlagFromComment(communityId, commentId, userId)
API Version
29.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags removeFlagFromComment(String communityId, String commentId, String userId)
Parameters
Return Value
Type: Void
Usage
removeFlagFromFeedElement(communityId, feedElementId, userId)
API Version
31.0
Requires Chatter
Yes
Signature
public static void removeFlagFromFeedElement(String communityId, String feedElementId, String userId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedElementId
- Type: String
- ID of the feed element.
- userId
- Type: String
- ID of the context user for whom the flag is removed. Specify null to remove the flag for all users.
Return Value
Type: ConnectApi.ModerationCapability
If the feed element doesn’t support this capability, the return value is ConnectApi.NotFoundException.
Usage
Retired CommunityModeration Methods
addFlagToFeedItem(communityId, feedItemId)
API Version
29.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToFeedItem(String communityId, String feedItemId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedItemId
- Type: String
- ID for a feed item.
Return Value
Usage
addFlagToFeedItem(communityId, feedItemId, visibility)
API Version
30.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags addFlagToFeedItem(String communityId, String feedItemId, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedItemId
Type: String
ID for a feed item.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types.
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Usage
getFlagsOnFeedItem(communityId, feedItemId)
API Version
29.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags getFlagsOnFeedItem(String communityId, String feedItemId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedItemId
- Type: String
- ID for a feed item.
Return Value
Usage
getFlagsOnFeedItem(communityId, feedItemId, visibility)
API Version
30.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags getFlagsOnFeedItem(String communityId, String feedItemId, ConnectApi.CommunityFlagVisibility visibility)
Parameters
communityId
Type: String
ID for an Experience Cloud site, internal, or null.
feedItemId
Type: String
ID for a feed item.
visibility
Type: ConnectApi.CommunityFlagVisibility
Visibility behavior of a flag for various user types. Values are:
- ModeratorsOnly—The flag is visible only to users with moderation permissions on the flagged element or item.
- SelfAndModerators—The flag is visible to the creator of the flag and to users with moderation permissions on the flagged element or item.
Return Value
Usage
removeFlagsOnFeedItem(communityId, feedItemId, userId)
API Version
29.0–31.0
Requires Chatter
Yes
Signature
public static ConnectApi.ModerationFlags removeFlagsOnFeedItem(String communityId, String feedItemId, String userId)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- feedItemId
- Type: String
- ID for a feed item.
- userId
- Type: String
- ID of the context user for whom the flag is removed. Specify null to remove the flag for all users.
Return Value
Type: Void