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
@CA@CA 

How to add multiple contacts to WhoId field of an event?

We have enabled shared activity feature so that we can add multiple contact to name field of an event.. It works from the UI..
But when we try to update WhoID field form the class it replaces the existing contact.. need some help in adding multiple events to the contact thru apex.
sample Method:

public void updateEvents(){

        for(Event Evt:[Select Id, WhoId from Event where Id =:selectedRecID]){
        Evt.WhoId=Id;
        updateEventList.add(Evt);
        }
        if(!updateEventList.isEmpty()){
        update updateEventList;
        }
       
    }

Any help on this will be apprecited.