Represents a person (User, Contact, or Lead) or resource (such as a conference room) invited to an Event. It allows you to add or remove invitees from an event, and
to manage invitee responses to invitations through the API.
When Shared Activities is enabled, the EventRelation object can also represent a Who or What object. Events can
have up to 11 relationships when relating to Contacts: 10 Contacts
and one other relationship to Account, Asset, Campaign, Case, Contract,
Opportunity, Product, Solution, or custom object. Events can have
up to two relationships when relating to Leads: one Lead and one other
relationship to Account, Asset, Campaign, Case, Contract, Opportunity,
Product, Solution, or custom object. The EventRelation object represents this relationship.
Account ID of the relation. For information on IDs, see ID Field Type. AccountId is visible when Shared Activities
is enabled.
EventId
Type
reference
Properties
Create, Filter, Group, Sort
Description
ID of the Event. This value can’t be changed after it’s been
specified.
IsDeleted
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Indicates whether the object has been moved to the Recycle Bin
(true) or not (false). Label is Deleted.
IsInvitee
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
Indicates whether or not the relation is an invitee.
IsInvitee is visible when Shared Activities
is enabled, or is in the process of being enabled or disabled.
IsInvitee defaults to true during enablement and rollback of
Shared Activities, and when Shared Activities is enabled if IsInvitee, IsParent, and IsWhat are not set. This ensures compatibility
for code written prior to enabling Shared Activities when EventRelation represents event attendees only.
IsInvitee defaults to false when Shared Activities is enabled
if IsParent is set to true.
IsParent
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
Indicates whether the relation is a Who or a What. IsParent is visible when Shared Activities is enabled.
IsWhat
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort
Description
Indicates whether the relation is a What. Value is false if RelationId is
a Contact, or Lead and true otherwise. IsWhat is visible when Shared Activities is enabled.
RelationId
Type
reference
Properties
Create, Filter, Group, Sort
Description
ID of the person (User, Contact, or Lead) or the resource invited to the Event. When Shared Activities for events is enabled, RelationId can also contain the ID of the event's Who or What.
This value can’t be changed after it’s been specified.
RespondedDate
Type
dateTime
Properties
Create, Filter, Nillable, Sort, Update
Description
Date and time when the attendee (invitee) responded.
Response
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Optional text that the attendee entered when responding to the
event request.
New—Invitee has received
the invitation but has not yet responded. This is the default value.
Declined—Invitee has
declined to attend the event.
Accepted—Invitee has
accepted the invitation to attend the event.
Usage
This object provides information about
who has been invited to attend a particular event and their response
to that invitation. A client application can, for example, query this
object for a given event, iterate through the list, examine the status,
and send email notifications to every person who accepted the invitation.
To determine all the events that a particular person is attending
during a given time period (for example, next week), a client application
can query the Event object for a given date range, iterate through the results
and, for each event, query the EventRelation object to determine whether the particular person (RelationId) has accepted an invitation to that event.
The EventRelation object is also used to indicate Shared Activities relationships
for events.
To create an invitee if Shared Activities is not
enabled, create an EventRelation object for the invitee. To create an invitee if Shared Activities
is being enabled or rolled back, or is enabled, and the invitee is
already a Who, update IsInvitee to true. If the invitee is not already a
Who, create an EventRelation object for the invitee with IsInvitee set
to true.
Query Who
Relations
List<EventRelation> whoRelations = [SELECT Id, Relation.Name FROM
EventRelation WHERE EventId = '00UD0000005zijD' AND isParent = true];
Query Invitee Relations
List<EventRelation> inviteeRelations = [SELECT Id, Relation.Name FROM
EventRelation WHERE EventId = '00UD0000005zijD' AND isInvitee = true];
Update an Invitee Relation to a Who Invitee Relation
EventRelation er = [SELECT Id FROM EventRelation WHERE EventId =
'00UD0000005zijD' AND isInvitee = true and isParent = false LIMIT 1];
er.isParent = true;
update er;
Update a Who Relation to a Who Invitee
Relation
EventRelation er = [SELECT Id FROM EventRelation WHERE EventId =
'00UD0000005zijD' AND isParent = true and isInvitee = false LIMIT 1];
er.isInvitee = true;
update er;
Insert a Who Relation
EventRelation er = new EventRelation(EventId = '00UD0000005zijH',
RelationId = '003D000000Q8aeV', isParent = true, isInvitee = false);
insert er;
Insert an Invitee Relation
If isParent, isWhat and IsInvitee are not set, and RelationId is either Contact, Lead, User or Calendar, IsInvitee defaults to true. This means
if an EventRelation isn’t specifically inserted as a Who relation,
it’s treated as an Invitee relation by default.
EventRealtion er = new EventRelation(EventId = '00UD0000005zijH',
RelationId = '003D000000Q8adV');
insert er;