+ Start a Discussion

How to relate different Event records of a multiple attendee event

When we create an Event involving another attendee (from the SF web UI for example), SF creates one Event record for each attendee. And then it adds one entry per attendee on the EventAttendee table, linking/poinint to the first/main record.




I login as U1, click on "New Event" in my homepage, add U2 as attendee for the event and save. This will create two Event records: E1 owned by U1 and E2 owned by U2. And it will add (U1, E1) and (U2, E1) on the EventAttendee object.


My question is: how do I programmaticaly know if two Event records "are the same event". Having two events E1 owned by U1 and E2 owned by U2, I've no exact way of telling if E2 is the Event record instance created for U2 as result of him being an attendee when U1 scheduled E1.


I've seen the IsGroupEvent field on the Event object which doesn't help much.


I tried catching E1 and E2 using a trigger and trying to relate in there, but (surprise!) when I save and then I check the logs, the trigger is only executed for E1. No visible trace of E2 on the logs, but SF is creating it and it exists.


I could apply some heuristics and say something like: if I've E2 owned by U2, U2 appears on EventAttendee pointing to E1, and E2 and E1 have the same date & subjects, then assume they're different records "of the same event".


But maybe there's something more direct/exact?


This is related to this previous post.


Any hint? Thanks a lot!




Equate the what id with the custom event you are creating





 if(e.whatId == eve.Id) {}


Thanks Steve. Sadly, it doesn't work. WhatId doesn't contain the Id of the "main" record (the one created by/for the creator User). BTW, these are all standard SF Event records, no custom ones.


Just compare Whatid of both events


Steve, WhatId is null in both records (which makes sense as I didn't set any value on the "Related To" field when creating the event).