0

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.

4
  • 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 Apr 3 '18 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 Apr 3 '18 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 Apr 3 '18 at 17:32
  • @DavidReed thank you. i have edited my question and added more detail. – echology Apr 3 '18 at 17:34
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.