WhoId (Name) field iss not getting populated through apex in Event object in Salesforce?

When "Allow Users to Relate Multiple Contacts to Tasks and Events" is enabled, WhoId cannot be set through Apex.

Once the event is created, create EventRelation record.

EventRelation obj = new EventRelation( EventId = Event Id );
obj.RelationId = Contact/LeadId;
obj.IsParent = true;
obj.IsInvitee = false;
insert obj;

Create multiple EventRelation records to attach multiple Leads/Contacts to the Event.

No comments:

Post a Comment