I'm trying to understand the Event sharing rules, as I have an Email Service that will run with minimal permissions and that needs to query Events by ID (event IDs will be present in the emails). This works unless there are no contacts associated to an Event.
In an org with Shared Activities enabled and the following Org-Wide Defaults for Sharing:
- Account, Contract and Asset: Public Read/Write
- Contact: Controlled by Parent
- Activities: Controlled by Parent
For any Event created with at least one Contact attending (such that Event.WhoId is populated), the "parent" of the event appears to be the Contact, and since Account sharing is Public Read/Write, everyone can see the Event; the Email Service can find the event. But if I create an event without a Contact, the email service cannot query the Event by Id. Adding a contact after initially creating the event does fix the issue for a given Event. Also - none of these Events have WhatIds assigned.
If an Event is created without a WhoId or WhatId, does it effectively have no parent? Is there any way to make it visible to other users who do not have "View all data" permissions?
Messaging.InboundEmailHandler
. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…without sharing
mode and then in that class try to fetch events.