Newer Version Available

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

Audience

Represents the audience in a community. An audience consists of different types of criteria, where the audience can be assigned and used for targeting in a community. This type extends the Metadata metadata type and inherits its fullName field.

File Suffix and Directory Location

Audience components have the suffix .audience and are stored in the audience folder.

Version

Audience components are available in API version 44.0 and later.

Special Access Rules

Access to the Audience type requires the AudienceMetadata permission. This permission is on by default for orgs that have Networks enabled.

Access to permission-based criteria for the Audience type requires the AudiencePermissionCriteria permission. This permission is available in API version 45.0 and later and is on by default for orgs that have Networks enabled.

Fields

Field Name Field Type Description
audienceName string Required. The name of the audience.
container string Required. The name of the community or org that contains the audience.
criterion AudienceCriterion[] List of criteria in an audience.
description string The description of the audience.
formula string Formula used to determine the audience. This field is available in API version 45.0 and later.
formulaFilterType FormulaFilterType​(enumeration of type string) Indicates the audience’s formula type. Valid values are
  • AllCriteriaMatch
  • AnyCriterionMatches
  • CustomLogicMatches (available in API version 45.0 and later)

AudienceCriterion

Represents a criterion for an audience.
Field Name Field Type Description
criteriaNumber int The number associated with the criterion in a formula, for example, (1 AND 2) OR 3. This field is available in API version 45.0 and later.
criterionValue AudienceCriteriaValue The value of the criterion.
operator AudienceCriterion​Operator(enumeration of type string) The operator associated with this criterion. Valid values are:
  • Equal
  • NotEqual
  • GreaterThan
  • GreaterThanOrEqual
  • LessThan
  • LessThanOrEqual
  • Contains
  • StartsWith
  • Includes (available in API version 45.0 and later)
  • NotIncludes (available in API version 45.0 and later)
type AudienceCriterion​Type(enumeration of type string) Valid values are:
  • GeoLocation
  • Domain
  • Profile
  • FieldBased
  • Permission (available in API version 45.0 and later)
For a list of AudienceCriteriaValue fields that you can use with each AudienceCriterion type field value, see this table.

AudienceCriteriaValue

Represents the value of a criterion in an audience. For a list of AudienceCriteriaValue fields that you can use with each AudienceCriterion type field value, see this table.
Field Name Field Type Description
city string City of a user. This field can be used only when the value of the AudienceCriterion type field is GeoLocation.
country string Country of a user. This field can be used only when the value of the AudienceCriterion type field is GeoLocation.
domain string Domain of a user. This field can be used only when the value of the AudienceCriterion type field is Domain.
entityField string Field of an object. This field can be used only when the value of the AudienceCriterion type field is FieldBased.
entityType string Type of object. This field can be used only when the value of the AudienceCriterion type field is FieldBased.
fieldValue string Value of a field. This field can be used only when the value of the AudienceCriterion type field is FieldBased.
isEnabled string Indicates whether the permission is enabled (true) or not (false) for a user. This field is available in API version 45.0 and later and can be used only when the value of the AudienceCriterion type field is Permission.
permissionName string Valid API name of a standard user or custom permission. This field is available in API version 45.0 and later and can be used only when the value of the AudienceCriterion type field is Permission.
permissionType string Type of permission. Valid values are Standard and Custom. This field is available in API version 45.0 and later and can be used only when the value of the AudienceCriterion type field is Permission.
profile string Profile of a user. This field can be used only when the value of the AudienceCriterion type field is Profile.
subdivision string Subdivision of a user. This field can be used only when the value of the AudienceCriterion type field is GeoLocation.
This table summarizes which AudienceCriteriaValue fields you can use with the different AudienceCriterion type field values.
AudienceCriterion Type AudienceCriteriaValue Fields
GeoLocation city

country

subdivision

Domain domain
Profile profile
FieldBased entityField

entityType

fieldValue

Permission isEnabled

permissionName

permissionType

Declarative Metadata Sample Definition

The following is an example of an Audience component.

1<?xml version="1.0" encoding="UTF-8"?>
2<Audience xmlns="http://soap.sforce.com/2006/04/metadata">
3    <audienceName>Audience Metadata</audienceName>
4    <container>Customer</container>
5    <criterion>
6        <criteriaNumber>1</criteriaNumber>
7        <criterionValue>
8            <country>United States</country>
9            <subdivision>Nevada</subdivision>
10        </criterionValue>
11        <operator>Equal</operator>
12        <type>GeoLocation</type>
13    </criterion>
14    <criterion>
15        <criteriaNumber>2</criteriaNumber>
16        <criterionValue>
17            <profile>customer community user</profile>
18        </criterionValue>
19        <operator>Equal</operator>
20        <type>Profile</type>
21    </criterion>
22    <criterion>
23        <criteriaNumber>3</criteriaNumber>
24        <criterionValue>
25            <domain>sampledomain.example.com</domain>
26        </criterionValue>
27        <operator>Equal</operator>
28        <type>Domain</type>
29    </criterion>
30    <criterion>
31        <criteriaNumber>4</criteriaNumber>
32        <criterionValue>
33            <entityField>Manager.Profile.CreatedBy.Contact.MailingCountry</entityField>
34            <entityType>User</entityType>
35            <fieldValue>USA</fieldValue>
36        </criterionValue>
37        <operator>StartsWith</operator>
38        <type>FieldBased</type>
39    </criterion>
40    <criterion>
41        <criteriaNumber>5</criteriaNumber>
42        <criterionValue>
43            <entityField>RecordTypeId</entityField>
44            <entityType>CollaborationGroup</entityType>
45            <fieldValue>CollaborationGroup.Group_RT2</fieldValue>
46        </criterionValue>
47        <operator>Equal</operator>
48        <type>FieldBased</type>
49    </criterion>
50    <criterion>
51        <criteriaNumber>6</criteriaNumber>
52        <criterionValue>
53            <isEnabled>true</isEnabled>
54            <permissionName>ManageUsers</permissionName>
55            <permissionType>Standard</permissionType>
56        </criterionValue>
57        <operator>Equal</operator>
58        <type>Permission</type>
59    </criterion>
60    <criterion>
61        <criteriaNumber>7</criteriaNumber>
62        <criterionValue>
63            <isEnabled>false</isEnabled>
64            <permissionName>NamespaceXYZ__CustomPermABC</permissionName>
65            <permissionType>Custom</permissionType>
66        </criterionValue>
67        <operator>Equal</operator>
68        <type>Permission</type>
69    </criterion>
70<formula>1 AND (2 OR 3 OR 4 OR 5 OR 6 OR 7)</formula>
71<formulaFilterType>CustomLogicMatches</formulaFilterType>
72</Audience>

Usage

You can’t delete an audience using Metadata API.

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.