I have a strange situation. A customer has a trigger on Event that sends an email to a given list of people when a new event is created. We recently enhanced this functionality and added the ability to resend the email.
One of the first lines in the email has the people invited to the event. The user creates an event with more than one related contact. In the trigger code we read from EvenWhoRelation to get the contacts that were associted to the event.
Here's the weird part, when the event is created in Lightning, everything works fine, all the attendees are retrieved.
When the event is created in Classic, only one attendee is retrieved from the same query. But, if you take the event created in Classic, switch to Lightning, and click our new resend button(uses the same code) all the attendees are retrieved.
In the sandbox I added debug statements around the query, and sure enough, in classic, only one record comes back, in lightning they're all returned...
I've looked and can't find any details on this online, can anyone point to why this is happening?
Edit: Tried following Daniels answer, but that bore no fruit.
I changed the following query:
SELECT RelationId, Type FROM EventWhoRelation WHERE EventId = :evt.Id AND (Type = 'Contact' OR Type = 'Lead')]
To
SELECT RelationId FROM EventRelation WHERE IsParent = true AND IsWhat = false AND IsInvitee = true AND EventId = :evt.Id
And the result was events created in classic still only found 1 related invitee, and events created in Lightning now found none. So even if I tried to determine the UI of the user, and switch queries based on that, the Classic one still does not work as intended.