18

Problem Statement

Show a list of events on visualforce page, and give ability to respond as accept/reject/maybe.

Scenario:

  • 3 users are participating in an event.
  • Event is created by a user named "Ab Jindal" and he invites two other sfdc users i.e. "Ab Dev" and "Sm Dev"
  • Here is event data with parent event and eventrelations created for owner "Ab Jindal" Event table query
  • EventRelation table data for this event: EventRelation table data

From above screenshots, its clear that one needs Parent Event Id to update any EventRelation. Even if we try to hack and create a new EventRelation record via invited user i.e. "Ab Dev" or "Sm Dev", it will fail. Here is sample failure code

EventRelation er = new EventRelation(
                           RelationId = UserInfo.getUserId()  ,  
                           EventId = '00U2000000VcrubEAB',
                           Status = 'Declined'
                     );

insert er;

Here is the error which comes on executing above code:

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OPERATION, You cannot create an Event Relation with a child event.: [EventId]

So, I wanted to know either of following two questions:

  • How we can get parent event id from a child event ?
  • Or, how to update child event with accept/decline/maybe info ?

Similar Questions

On researching found this post which is somewhat close to my challenge, but is not having correct resolution.

2 Answers 2

1

Event Relation records to be inserted always with status as "New" but, later it can be updated to "Accepted" or "Declined" .

Insert :

EventRelation er = new EventRelation( RelationId = UserInfo.getUserId() ,
EventId = '00U2000000VcrubEAB', Status = 'New' );

insert er;

Update :

Get event id from event object. Then query to Event Relation and get the id(event relation record id) ;

EventRelation er = new EventRelation( Id = "EventRelation rec id",
Status = 'Declined' );

update er;

-1

To decline the status, you will have to perform update not insert. Eventid & Relationid is not required to accept or reject the event.

1
  • As described in the question, I am unable to do update, as ParentId is not available on child event. So without getting a correct parentid, its not possible. Aug 18, 2014 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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