I want to add "User" invitees to an event through eventRelation. I am doing this through an additional Event.OwnerId field in the custom layout. When the user saves the record for event, an eventRelation record should be created.

This is the code I have written so far...

                    EventRelation eventR = new EventRelation();
                    eventR.EventId = evnt.Id;
                    eventR.RelationId = evt.OwnerId;
                    eventR.isWhat = false;
                    eventR.isParent = false;
                    eventR.IsInvitee = True;
                    eventR.Status = 'New';
                    insert eventR;

In the code above i am getting the eventId once the event record has been inserted. After that i am creating the eventRelation record with the additional OwnerId field value placed in the layout.

The problem is that eventRelation record is created at first with an insert id being returned without any errors or exception of any kind but later when the EventRelation is queried, the record is gone.

I also tried to set the GroupEventType to 1 (required for multiple invitees) but this field was not writable.

Note: Activity sharing feature is enabled

Any help will be appreciated.

  • 1
    What does "an additional Event.OwnerId field" mean? When you execute the insert, does an error happen? Do you have a try/catch block around this code? Is this code running in a trigger, and if so, what trigger event?
    – David Reed
    Commented Apr 3, 2018 at 13:13
  • @DavidReed thank you DavidReed. No exception or error of any kind occurs at the eventRelation creation. Though it inserts the eventRelation data with a legitimate insert id being returned but later on when the eventRelation record is queried, the record is gone. No trigger is in place for any sort of manipulation on EventRelation object.
    – echology
    Commented Apr 3, 2018 at 17:29
  • That doesn't match the body of your question, where you say that the record "is not created". I really think you need to add some more information and clarity here to find an answer.
    – David Reed
    Commented Apr 3, 2018 at 17:32
  • @DavidReed thank you. i have edited my question and added more detail.
    – echology
    Commented Apr 3, 2018 at 17:34

1 Answer 1


The issue has been resolved. Actually it was something wrong with the code. Right after the event was inserted with the new User invitees the event data was being updated without the User Invitees. So the final event was always turning out to be a single user event.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .