EventRelation

Represents people (a user, a lead, or contacts) or a resource (such as a conference room) invited to an event. This object lets you add or remove invitees from an event and use the API to manage invitees’ responses to invitations. If Shared Activities is enabled, this object doesn’t support triggers, workflow, or data validation rules.

EventRelation allows a variable number of relationships and handles deleted events differently, depending on whether Shared Activities is enabled.

If Shared Activities Is Enabled
  • An event can be related to up to 50 contacts or one lead.
  • If you delete an event, then relations between the event and any specified contacts, leads, and records are also deleted. The WhoId, WhatId, and AccountId field values are cleared. If you restore a deleted event, relations between the event and any specified contacts, leads, and records are also restored. The WhoId, WhatId, and AccountId field values are recalculated using the field values on EventRelation.
If Shared Activities Isn’t Enabled
  • An event can be related to only one contact or lead.
  • If you delete an event, the WhoId, WhatId, and AccountId field values aren’t cleared.

Whether or not Shared Activities is enabled, an event can be related to one other kind of record, such as an account, an opportunity, or a custom object (in addition to one or more contacts).

Note
  • With API versions 26.0 and later, the EventRelation object replaces the EventAttendee object, and the EventAttendee object is no longer visible. You can still query the EventAttendee object using packages that support API versions 25.0 and earlier, or by using Apex.
  • An EventRelation object can’t be created for a child event.
  • EventRelation includes deactivated users.
  • In API versions 25.0 and earlier, you can’t use query(), delete(), or update() with events related to more than one contact.

Supported Calls

create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), queryAll(), retrieve(), update(), upsert()

Fields

Field Details
AccountId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
Contains the 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
Contains the 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 the relation is an invitee.
  • IsInvitee is visible while Shared Activities is being enabled, after it has been enabled, and while it is being disabled.
  • IsInvitee defaults to true while Shared Activities is being enabled, after it has been enabled, and while it is being disabled if IsInvitee, IsParent, and IsWhat are not set. This configuration ensures compatibility when Shared Activities isn’t enabled and EventRelation represents event invitees 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 contact or lead, or an account, opportunity, or other object. 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 an account, an opportunity, or another object. Value is false if RelationId is a contact or a lead, and true otherwise. IsWhat is visible when Shared Activities is enabled.
RelationId
Type
reference
Properties
Create, Filter, Group, Sort
Description
Contains the ID of the person (User, Contact, or Lead) or the resource invited to an event. When Shared Activities is enabled, RelationId can also contain the ID of the contacts or lead related to an event.

This value can’t be changed after it’s been specified.

RespondedDate
Type
dateTime
Properties
Create, Filter, Nillable, Sort, Update
Description
Indicates the most recent date and time when the invitee responded to an invitation to an event.
Response
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Contains optional text that the invitee can enter when responding to an invitation to an event.
Status
Type
picklist
Properties
Create, Filter, Group, Nillable, Restricted picklist, Sort, Update
Description
Indicates the invitee status with one of the following values:
  • New: Invitee has received the invitation but hasn’t yet responded. This value is the default.
  • Declined: Invitee has declined the invitation.
  • Accepted: Invitee has accepted the invitation.
Note
Uninvited and Maybe aren’t currently supported.

Usage

Send email notifications
To send email notifications for a given event, query EventRelation for the event, iterate through the list, examine the status, and send email notifications to every person who accepted the invitation.
Determine what events a given invitee is attending
To determine all the events that a particular person is attending during a given time period (for example, next week), you can have a client application 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.
Create an invitee if Shared Activities is enabled (or during the process of enabling it or rolling back)
If the invitee is already a contact or lead, update IsInvitee to true.
If the invitee is not already a contact or lead, create an EventRelation object for the invitee with IsInvitee set to true.
Create an invitee if Shared Activities is not enabled
Create an EventRelation object for the invitee.
Query relations to a contact or a lead
List<EventRelation> whoRelations = [SELECT Id, Relation.Name FROM 
    EventRelation WHERE EventId = '00UD0000005zijD' AND isParent = true AND isWhat = false];
Query invitee relations
List<EventRelation> inviteeRelations = [SELECT Id, Relation.Name FROM 
    EventRelation WHERE EventId = '00UD0000005zijD' AND isInvitee = true];
Update an invitee relation to a contact or lead 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 contact or lead relation to a contact or lead 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 contact or lead 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 a contact, lead, user, or calendar, IsInvitee defaults to true. This means if an EventRelation isn’t specifically inserted as a relation to a contact or lead, it’s treated as an Invitee relation by default.

EventRelation er = new EventRelation(EventId = '00UD0000005zijH', 
    RelationId = '003D000000Q8adV');
insert er;
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.