function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mathew Andresen 5Mathew Andresen 5 

changing recurring events

 built a reporting calendar that displays events and allows you to filter by department etc. It also includes some additional event fields such as completed.
Then my users create recurring events for reports (say every Monday do event X) that they need to mark complete.
But when trying to mark the event complete through apex I get the following error
"You cannot reassign a recurring event occurrence"
Note going back and changing the recurring event won't work, because I want to change each event individually, even if it started as a recurrence.
Any ideas on how to do this besides creating my own apex method that creates recurring events?
 
@AuraEnabled
    public static List<Event> getEventList(Decimal month, Decimal year) {
        Integer workingMonth = (Integer)month;
        Integer workingYear = (Integer)year;
        system.debug('year ' + year);
        system.debug('currentMonth' + workingMonth);
        List<Event> eventList = [SELECT Subject, Id, StartDateTime, Department__c, Out_Of_Office__c, Status__c, Reporting_Calendar__c FROM Event 
                                 WHERE (CALENDAR_MONTH(StartDateTime) = :workingMonth AND CALENDAR_YEAR(StartDateTime) = :workingYear) AND Reporting_Calendar__c=true AND isRecurrence=false]; //
        system.debug(eventList);
        return eventList;
    }
    
    @AuraEnabled
    public static Event getNewEvent(Event newEvent) {
        String userId = UserInfo.getUserId();
        newEvent.OwnerId = userId;
        upsert newEvent;
        system.debug(newEvent);
        return newEvent;
    }

 
Mathew Andresen 5Mathew Andresen 5
Here is my current solution that seems to be working.  Basically delete the specific event and make a new one with the details of the deleted one
 
@AuraEnabled
        public static Event getEditEvent(Event newEvent) {
        Event oldEvent = newEvent;
        delete oldEvent;
        newEvent.Id = null;
        newEvent.DurationInMinutes = 60;
        upsert newEvent;
        system.debug(newEvent);
        return newEvent;
    }