Salesforce Asked by Abhinav Gupta on December 27, 2020
Problem Statement
Show a list of events on visualforce page, and give ability to respond as accept/reject/maybe.
Scenario:
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:
Similar Questions
On researching found this post which is somewhat close to my challenge, but is not having correct resolution.
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;
Answered by Rajesh Kumar on December 27, 2020
To decline the status, you will have to perform update not insert. Eventid & Relationid is not required to accept or reject the event.
Answered by user11048 on December 27, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP