Newer Version Available
ModerationRule
- Your org can have up to 30 rules. This limit is per org, not per community. This limit includes both content rules and rate rules.
- Each rule can have up to three keyword criteria.
- Rules that block content run first, followed by rules to review and approve content, then rules that replace content, and last by rules that flag content. If two or more rules perform the same action, the oldest rule runs first, based on the date the rule was created. Rules to replace content don’t run when the content also applies to a review rule—we want community managers to review the original content.
File Suffix and Directory Location
ModerationRule components have the suffix .rule and are stored in the moderation directory of the corresponding package directory. The file name format follows community_name.moderation_rule_developer_name.rule.
Version
ModerationRule components are available in API version 36.0 and later.
Special Access Rules
To view, create, edit, and delete moderation rules, you need the Manage Communities or Create and Set Up Communities permission.
Fields
| Field Name | Field Type | Description |
|---|---|---|
| action | ModerationRuleAction (enumeration of type string) |
Required. Indicates the moderation action that you want to
take. The valid values are:
|
| actionLimit | int | Indicates the moderation action limit. Available in API 39.0 and later. |
| active | boolean | Required. Indicates whether the moderation rule is active (true) or inactive (false). |
| description | string | A description of the moderation rule. |
| entitiesAndFields | ModeratedEntityField[] | Indicates the types of user-generated content this moderation rule applies to. |
| masterLabel | string | Required. Label for the moderation rule. |
| notifyLimit | int | Indicates the notification limit of the moderation rule. Available in API 39.0 and later. |
| userCriteria | string | Represents the member criteria to use in community moderation rules. Available in API 39.0 and later. |
| userMessage | string | The message you want your community members to see when their content is blocked. Use the %BLOCKED_KEYWORD% variable to display up to five blocked words in the user message. If you don’t specify a message, the member sees the standard message: “You can’t use %BLOCKED_KEYWORD% or other inappropriate words in this community. Review your content and try again.” |
ModeratedEntityField
The fields and entities you want to moderate.
| Field Name | Field Type | Description |
|---|---|---|
| entityName | string | Required. Indicates the types of user-generated content the moderation rule applies to. Post and comments only apply to content created in groups and user profiles. All feed types, such as polls and links, are supported. |
| fieldName | string | Indicates the field the moderation rule applies to. |
| keywordList | KeywordList string | Indicates the keyword list that you want to moderate against. |
ModerationRuleType
Required. Indicates the type of rule to run on user-generated content.
| Field Name | Field Type | Description |
|---|---|---|
| type | (enumeration of type string) |
Required. Indicates the type of rule to run on
user-generated content. Valid values are:
|
RateLimitTimePeriod
Required. Indicates the time period that is applied to the rate limit.
| Field Name | Field Type | Description |
|---|---|---|
| timePeriod | (enumeration of type string) |
Required. Indicates the time period that is
applied to the rate limit. Valid values are:
|
Declarative Metadata Sample Definition
The following is an example of a ModerationRule component.
1<?xml version="1.0" encoding="UTF-8"?>
2<ModerationRule xmlns="http://soap.sforce.com/2006/04/metadata">
3 <description>Blocks Bad Word List in posts, comments, Link URLs, titles, and poll choices.</description>
4 <masterLabel>Blocking Rule</masterLabel>
5 <action>Block</action>
6 <active>true</active>
7 <userMessage>You can't use %BLOCKED_KEYWORD% or other inappropriate words in this community. Review your content and try again.</userMessage>
8 <!-- Applies the rule to FeedComment.RawCommentBody (an internal only field), if it contains words from the keyword list specified -->
9 <entitiesAndFields>
10 <entityName>FeedComment</entityName>
11 <fieldName>RawCommentBody</fieldName>
12 <keywordList>community1.badword_list</keywordList>
13 </entitiesAndFields>
14 <entitiesAndFields>
15 <entityName>FeedItem</entityName>
16 <fieldName>LinkUrl</fieldName>
17 <keywordList>community1.badword_list</keywordList>
18 </entitiesAndFields>
19 <!-- Applies the rule to FeedItem.RawBody (an internal only field), if it contains words from the keyword list specified -->
20 <entitiesAndFields>
21 <entityName>FeedItem</entityName>
22 <fieldName>RawBody</fieldName>
23 <keywordList>community1.badword_list</keywordList>
24 </entitiesAndFields>
25 <entitiesAndFields>
26 <entityName>FeedItem</entityName>
27 <fieldName>Title</fieldName>
28 <keywordList>community1.badword_list</keywordList>
29 </entitiesAndFields>
30 <entitiesAndFields>
31 <entityName>FeedPollChoice</entityName>
32 <fieldName>ChoiceBody</fieldName>
33 <keywordList>community1.badword_list</keywordList>
34 </entitiesAndFields>
35</ModerationRule>The following is an example package.xml that references the previous definition.
1<?xml version="1.0" encoding="UTF-8"?>
2<Package xmlns="http://soap.sforce.com/2006/04/metadata">
3 <types>
4 <name>ModerationRule</name>
5 <members>community1.blocking_rule</members>
6 </types>
7 <version>36.0</version>
8</Package>