I am attempting to create a calendar view object for my users. It is my first forray into Apex programming, so I have been referencing the example code in the developer docs.
I ran into an issue with the example code - it does not compile.
This is the documentation that I am reading/following for the CalendarView object.
The code in question is here:
Group userGroup = [SELECT Id FROM Group WHERE Name = 'Sales Group' LIMIT 1];
List<Id> groupId = new List<Id>();
groupId.add(userGroup.id);
List<GroupMember> groupMembers = [SELECT UserOrGroupId FROM GroupMember
WHERE GroupId IN: groupId];
List<CalendarView> calendarViews = new List<CalendarView>();
for (GroupMember groupMember : groupMembers) {
CalendarView calendarView = new CalendarView(name = 'Opportunity Close
Dates', SobjectType = 'Opportunity', StartField = 'CloseDate', DisplayField =
'Name', OwnerId = groupMember.UserOrGroupId);
calendarViews.add(calendarView);
}
insert calendarViews;
By default, this code does not compile and I recieve error message:
Error: Compile Error: Unexpected token ')'. at line 4 column 25
From what I can understand, this code to me is properly formatted. We create a group named userGroup. We then create a list named groupId. In the list, we are attempting to add the id from the group we just created.
Group userGroup = [SELECT Id FROM Group WHERE Name = 'Sales Group' LIMIT 1];
List<Id> groupId = new List<Id>();
groupId.add(userGroup.id);
Nothing seems out of the ordinary to me, but even with just these 3 lines and modifying the group name from 'Sales Group' to something actually real in my salesforce environment I still receive nothing but the compile error as a response.