Newer Version Available
CalendarView
These calendars can be created and assigned to users other than the
creator. Available calendars include object, shared, public, resource, and user list
calendars. Object calendars represent a calendar based on a Salesforce object, either
standard or custom. This object is available in API version 51.0 and
later.
Supported Calls
create(), delete(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), undelete(), update(), upsert()
Special Access Rules
All fields and entities referenced by field values must be accessible by the CalendarView creator even if the creator isn’t the CalendarView owner.
Fields
| Field | Details |
|---|---|
| Color |
|
| CurrencyIsoCode |
|
| DateHandlingType |
|
| DisplayField |
|
| EndField |
|
| FillPattern |
|
| IsDisplayed |
|
| ListViewFilterId |
|
| Name |
|
| OwnerId |
|
| PublisherId |
|
| SobjectType |
|
| StartField |
|
Usage
To distribute a CalendarView to multiple users, IDs can be pulled from a group, user list, or profile. For this example, a CalendarView based on opportunity close dates is being distributed to a sales team in a public group, Sales Group:
1Group userGroup = [SELECT Id FROM Group WHERE Name = 'Sales Group' LIMIT 1];
2List<Id> groupId = new List<Id>();
3groupId.add(userGroup.id);
4List<GroupMember> groupMembers = [SELECT UserOrGroupId FROM GroupMember
5 WHERE GroupId IN: groupId];
6
7List<CalendarView> calendarViews = new List<CalendarView>();
8for (GroupMember groupMember : groupMembers) {
9 CalendarView calendarView = new CalendarView(name = 'Opportunity Close
10 Dates', SobjectType = 'Opportunity', StartField = 'CloseDate', DisplayField =
11 'Name', OwnerId = groupMember.UserOrGroupId);
12 calendarViews.add(calendarView);
13}
14insert calendarViews;