Home SALESFORCEAPEX How to identify the Parent Event ID from Child Event in Salesforce?

How to identify the Parent Event ID from Child Event in Salesforce?

Using Apex Class/Trigger if we tried to update the Events (Child Events) if isChild = True, then the following error is occur:

Report Status: You can not update fields except ReminderDateTime and IsReminderSet on a child event.

so in the child events, system only allowed to edit the ReminderDateTime and IsReminderSet fields in Event.

Field details in Event:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_event.htm

When Child Event Created in Salesforce:
While creating a new event/edit the event, we have the ability to invitee the peoples in that particular events, so after invitee the users/contact/leads then in salesforce internally created the seperate events for each invitee with the flag as isChild=TRUE

How to solve:
instead of update the events in childs (isChild = True), we need to identify the Parent Event (isChild = False) for the child and we can update the events without any issues.

How to identify the Parent Events from Child:
Unfortunately we can’t retrieve the parent Event id from a given Child Event directly, but its possible following work around.

Given an Event ID, to find it’s parent, look for an event that has –
1. The same WhatId
2. The same Subject
3. IsChild = false
4. StartDateTime

The only Issue in this approach is that if you have two events with the same WhatId, Subject and StartDateTime, then the query result will return two parent events.

SOQL:
select id, isChild, subject, whatId, whoId, groupeventtype, isgroupevent, isprivate, ownerid, accountid from event where ischild = false and subject = ‘Meeting’ and WhatId = ‘001D000001IdRjE’.

You may also like

Leave a Comment