Event
Supported Calls
create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), undelete(), update(), upsert()
Fields
Field | Details |
---|---|
AcceptedEventInviteeIds | |
AccountId |
|
ActivityDate |
|
ActivityDateTime |
|
ClientGuid |
|
CurrencyIsoCode | |
DeclinedEventInviteeIds | |
Description |
|
Division |
|
DurationInMinutes |
|
EndDate |
|
EndDateTime |
|
EventSubtype | |
EventWhoIds |
|
GroupEventType |
|
IsAllDayEvent |
|
IsArchived |
|
IsChild |
|
IsClientManaged |
|
IsGroupEvent |
|
IsPrivate |
|
IsRecurrence |
|
IsRecurrence2 |
|
IsRecurrence2Exception |
|
IsRecurrence2Exclusion |
|
IsReminderSet | |
IsVisibleInSelfService |
|
Location |
|
OwnerId |
|
Recurrence2PatternStartDate |
|
Recurrence2PatternText |
|
Recurrence2PatternTimeZone |
|
Recurrence2PatternVersion |
|
RecurrenceActivityId |
|
RecurrenceDayOfMonth |
|
RecurrenceDayOfWeekMask |
|
RecurrenceEndDateOnly |
|
RecurrenceInstance |
|
RecurrenceInterval |
|
RecurrenceMonthOfYear |
|
RecurrenceStartDateTime |
|
RecurrenceTimeZoneSidKey |
|
RecurrenceType |
|
ReminderDateTime |
|
ShowAs |
|
StartDateTime |
|
Subject |
|
Type |
|
UndecidedEventInviteeIds | |
WhatCount |
|
WhatId |
|
WhoCount |
|
WhoId |
|
Usage
Use Event to manage calendar appointments.
Querying and Filtering Events
Queries on events are denied before they time out if they involve amounts of data that are deemed too large. In such cases, the exception code OPERATION_TOO_LARGE is returned. If you receive OPERATION_TOO_LARGE, refactor your query to return or scan a smaller amount of data.
- One filter with the ActivityDate field equal to the Coordinated Universal Time (UTC) time zone on February 14, 2003.
- One filter with the ActivityDate field greater than or equal to midnight on February 14, 2003 in the user’s local time zone AND less than or equal to midnight on February 15, 2003 in the user’s local time zone.
Alternatively, in API version 13.0 and later, you can find events with a specific due date by filtering on StartDateTime. For example, to find all events with a due date of February 14, 2003, filter with the StartDateTime greater than or equal to midnight on February 14, 2003 in the user's local time zone AND less than or equal to midnight on February 15, 2003 in the user's local time zone.
The EventId field of an EventRelation object always points to the master record. An invitee on a group event can query the EventRelation object to view the master record.
- Multiday events are available in API version 13.0 and later. Also, in earlier versions SOQL queries don’t return multiday events.
- Multiday events are enabled through the user interface from Setup by entering Activity Settings in the Quick Find box, then selecting Activity Settings.
- If the multiday event feature is enabled, then API versions 13.0 and later support values greater than 1440 for the DurationInMinutes field. API versions 12.0 and earlier can’t access event objects whose DurationInMinutes is greater than 1440.
- Multiday events can’t exceed 14 days.
Event Series and Recurring Events
In Lightning Experience, events with multiple occurrences are called event series, and are indicated when the IsRecurrence2 field is set to true. In Salesforce Classic, events with multiple occurrences are called recurring events, and are indicated when the IsRecurrence field is set to true. Both fields can’t be set to true for the same event.
- Lightning Experience event series are available in API version 44.0 and later as read-only fields. Recurrence patterns, specified by the Recurrence2PatternText field, are creatable in API version 52.0 and later. Salesforce Classic recurring events are available in API version 7.0 and later. In earlier versions, SOQL queries don’t return any Lightning Experience event series.
- After an event is created, you can’t change the values of IsRecurrence2 or IsRecurrence from true to false or vice versa.
- You can’t set fields associated with IsRecurrence2 for events where IsRecurrence is set to true, or vice versa.
- For Lightning Experience event series where IsRecurrence2 is true, if you’d like to delete a single or all remaining events, use the REST API call. For Salesforce Classic recurring events where IsRecurrence is true, all past and future events in the series are removed when you delete the recurring event series through the API. However, when you delete the recurring event series through the user interface, only future occurrences are removed.
- For Lightning Experience event series in API version 58.0 and later, when you change a future event, events in the entire series also change. When you change a past event, IsRecurrence2Exception is set to true and only that past event changes.
- When creating a Salesforce Classic recurring event series, the duration of the event must be 24 hours or less. When the Salesforce Classic recurring event series is created, you can extend the length of individual occurrences beyond 24 hours if Multiday events are enabled; see Multiday Events.
- For Salesforce Classic recurring events, RecurrenceStartDateTime, RecurrenceEndDateOnly, RecurrenceType, and any properties associated with the given recurrence type (see the Recurrence Field Usage for Salesforce Classic Recurring Events table) must be populated.
- When updating a Salesforce Classic recurring event series, it’s not possible to update the EventRelation for the event series object and the EventRelation for the series object occurrences at the same time.
- Lightning Experience event series have no series ID, so it’s not possible to locate other occurrences in the series. In Salesforce Classic recurring events, you can use RecurrenceActivityId to locate other occurrences.
- For both Lightning Experience event series and Salesforce Classic recurring events, when a series repeats every day, month, or year, you can only schedule occurrences one time per day, month, or year. The week option lets you schedule occurrences multiple days per week.
Limits for Lightning Experience event series and limits for Salesforce Classic recurring events also apply.
Lightning Experience Event Series and Recurring Events
Recurrence Pattern | RRULE Example |
---|---|
Every day for five days | RRULE:FREQ=DAILY;INTERVAL=1;COUNT=5 |
Every Monday, Tuesday, Wednesday, Thursday, and Friday with no end date | RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR |
Every two weeks on Monday and Friday for 10 occurrences | RRULE:FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,FR;COUNT=10 |
Monthly on the first day of the month until January 1, 2020 | RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=1;UNTIL=20200101T100000Z |
Yearly on July 4th for three years (in this example, specify the date using StartDateTime) | RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYMONTHDAY=4;COUNT=3 |
Daily until January 1, 2022 with no end date | RRULE:FREQ=DAILY;UNTIL=20220101T000000Z |
Every third Friday of the month with no end date | RRULE:FREQ=MONTHLY;BYSETPOS=3;BYDAY=FR |
The RRULE defined by Recurrence2PatternText supports a subset of the RFC 5545 standard for internet calendaring and scheduling. Supported RRULE parts include FREQ, BYMONTH, BYMONTHDAY, BYDAY, WKST, BYSETPOS, INTERVAL, UNTIL, and COUNT.
- The RRULE parts are placed in the following order: FREQ, BYMONTH, BYMONTHDAY, BYDAY, WKST, BYSETPOS, INTERVAL, UNTIL, and COUNT.
- Any missing default values are inserted. For example, if the RRULE doesn't include INTERVAL, then INTERVAL=1 is added.
- The RRULE is prefaced with RRULE: if that preface is missing.
RRULE Part | Supported RFC 5545 Implementation |
---|---|
FREQ | Required. Indicates the type of recurrence rule. Allowed
values are:
|
BYMONTH | The month. Valid values are 1 to 12. |
BYMONTHDAY | The day of the month. Valid values are 1 to 31. If BYMONTHDAY is 31 and the month has fewer than 31 days, the event is created on the last day of the month. |
BYDAY | A comma-separated list of days of the week. Valid values are
SU, MO, TU, WE,
TH, FR, SA. For RRULES with yearly or monthly frequency,
BYDAY must be one of:
Each BYDAY value can be preceded by an integer that indicates the nth occurrence of a specific day within the monthly or yearly RRULE. Allowed values are -1, 1, 2, 3, and 4. You can't use different numbers in the BYDAY values. For example, this RRULE isn’t supported: RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=1SU,-1SU If BYDAY values are prefaced with a number, the RRULE can't include BYSETPOS. |
WKST | Specifies the day on which the workweek starts. Valid values are MO, TU, WE, TH, FR, SA, and SU. Default value is based on the user's locale. |
BYSETPOS | A comma-separated list of values that correspond to the nth
occurrence within the set of recurrence instances specified by
the rule. Valid values are -1, 1,
2, 3, or 4. Default value is 1. For example, to indicate the last weekday of the month, use: RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 |
INTERVAL | The repetition interval. Valid values are:
|
UNTIL | Specifies the datetime in UTC format when the recurrence rule
stops. The supported format is yyyyMMddTHHmmssZ, for example:
20210419T083000Z. An RRULE can't contain both UNTIL and COUNT. A recurring event without either UNTIL or COUNT repeats indefinitely. |
COUNT | The number of occurrences. Allowed values are 1 to 999. An RRULE can't contain both UNTIL and COUNT. A recurring event without either UNTIL or COUNT repeats indefinitely. |
BYWEEKNO | Specifies a comma-separated list of values that specify weeks
of the year. Valid values are:
For example, to indicate specific weeks in a year, use: RRULE: BYWEEKNO=20, -20. This rule part can’t be used when the FREQ rule part is set to anything other than YEARLY. For example, 3 represents the third week of the year. Note: Assuming a Monday week start, week 53 can only occur when Thursday is January 1 or if it’s a leap year and Wednesday is January 1. |
BYYEARDAY | Specifies a comma-separated list of values that specify days
of the year. Valid values are:
For example, to indicate specific days in a year, use: RRULE:BYYEARDAY=1,100,200; or, RRULE:BYYEARDAY=1,-2. |
Salesforce Classic Event Series and Recurring Events
This table describes the usage of recurrence fields for Salesforce Classic recurring events. Each recurrence type must have all of its properties set. All unused properties must be set to null.
RecurrenceType Value | Properties | Example Pattern |
---|---|---|
RecursDaily | RecurrenceInterval | Every second day |
RecursEveryWeekday | RecurrenceDayOfWeekMask | Every weekday - can’t be Saturday or Sunday |
RecursMonthly | RecurrenceDayOfMonth RecurrenceInterval | Every second month, on the third day of the month |
RecursMonthlyNth | RecurrenceInterval RecurrenceInstance RecurrenceDayOfWeekMask | Every second month, on the last Friday of the month |
RecursWeekly | RecurrenceInterval RecurrenceDayOfWeekMask | Every three weeks on Wednesday and Friday |
RecursYearly | RecurrenceDayOfMonth RecurrenceMonthOfYear | Every March on the 26th day of the month |
RecursYearlyNth | RecurrenceDayOfWeekMask RecurrenceInstanceRecurrenceMonthOfYear | The first Saturday in every October |
Attendees, Invitees, and Resources
The field GroupEventType indicates that event participants are included on an event. You can add a resource to an event only when the resource is available. The only attendance status that can be assigned to resources is Accepted. Events can’t be saved when resources you’ve added aren’t available.
JunctionIdList
public void createEventNew(Contact[] contacts) {
String[] contactIds = new String[contacts.size()];
for (int i = 0; i < contacts.size(); i++) {
contactIds[i] = contacts[i].getID();
}
Event event = new Event();
event.setSubject("New Event");
event.setEventWhoIds(contactIds);
SaveResult[] results = null;
try {
results = connection.create(new Event[] {
task
});
} catch (ConnectionException ce) {
ce.printStackTrace();
}
}
Syncing Events with Lightning Sync
Attendee statuses (Accepted or Maybe, Declined, or No Response) sync from Microsoft® Exchange or Google to Salesforce, but not from Salesforce to Exchange or Google. Be wary of creating API flows that update attendee status in Salesforce for users set up to sync both ways. Eventually the original Exchange or Google status overrides the update made in Salesforce.
Metadata deployments that include field-level security for only one of either the Event or Task objects can cause field-level security changes to the other object that aren't reflected in the metadata.
- If field-level security is enabled for one object, then field-level security is enabled for both objects.
- If field-level security is disabled for one object, then it's disabled for both objects.
Associated Objects
This object has the following associated objects. If the API version isn’t specified, they’re available in the same API versions as this object. Otherwise, they’re available in the specified API version and later.
- EventChangeEvent (API version 44.0)
- Change events are available for the object.
- EventFeed (API version 20.0)
- Feed tracking is available for the object.