EventRelation allows a variable number of relationships and handles deleted events differently, depending on whether Shared Activities is enabled.
A non-recurring event can have up to 1,000 invitees. A recurring event can have up to 100 invitees.
OR
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.
create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), queryAll(), retrieve(), update(), upsert()
Field | Details |
---|---|
AccountId |
|
EventId |
|
IsDeleted |
|
IsInvitee |
|
IsParent |
|
IsWhat |
|
RelationId |
|
RespondedDate |
|
Response |
|
Status |
|
If you use Shared Activities in your Salesforce org, use this query:
SELECT RelationId FROM EventRelation WHERE isInvitee = true AND eventId='[Event_Id]'
where Event_Id is the child event’s ID.
If you don’t use Shared Activities, use this query:
SELECT RelationId FROM EventRelation WHERE eventId='[Event_Id]'
These queries get the main event’s relations and display them for the given child event. To further filter the results, add a WHERE clause.
List<EventRelation> whoRelations = [SELECT Id, Relation.Name FROM EventRelation WHERE EventId = '00UD0000005zijD' AND isParent = true AND isWhat = false];
List<EventRelation> inviteeRelations = [SELECT Id, Relation.Name FROM EventRelation WHERE EventId = '00UD0000005zijD' AND isInvitee = true];
EventRelation er = [SELECT Id FROM EventRelation WHERE EventId = '00UD0000005zijD' AND isInvitee = true and isParent = false LIMIT 1]; er.isParent = true; update er;
EventRelation er = [SELECT Id FROM EventRelation WHERE EventId = '00UD0000005zijD' AND isParent = true and isInvitee = false LIMIT 1]; er.isInvitee = true; update er;
EventRelation er = new EventRelation(EventId = '00UD0000005zijH', RelationId = '003D000000Q8aeV', isParent = true, isInvitee = false); insert er;
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;
If you use Shared Activities in your Salesforce org, use the following query to reproduce the full site functionality in the Salesforce app:
SELECT RelationId FROM EventRelation WHERE isInvitee = true AND eventId='[Event_Id]'
where Event_Id is the child event’s ID.
If you don’t use Shared Activities, use this query:
SELECT RelationId FROM EventRelation WHERE eventId='[Event_Id]'
These queries get the main event’s relations and display them for the given child event. To further filter the results, add a WHERE clause.